| 1 |
; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s |
| 2 |
; Control Flow Guard is currently only available on Windows |
| 3 |
|
| 4 |
; CHECK: @feat.00 = 2048 |
| 5 |
|
| 6 |
; CHECK: .section .gfids$y |
| 7 |
; CHECK: .symidx "?address_taken@@YAXXZ" |
| 8 |
; CHECK: .symidx "?virt_method@Derived@@UEBAHXZ" |
| 9 |
|
| 10 |
; ModuleID = 'cfguard.cpp' |
| 11 |
source_filename = "cfguard.cpp" |
| 12 |
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" |
| 13 |
target triple = "x86_64-pc-windows-msvc" |
| 14 |
|
| 15 |
%struct.Derived = type { %struct.Base } |
| 16 |
%struct.Base = type { ptr } |
| 17 |
%rtti.CompleteObjectLocator = type { i32, i32, i32, i32, i32, i32 } |
| 18 |
%rtti.TypeDescriptor13 = type { ptr, ptr, [14 x i8] } |
| 19 |
%rtti.ClassHierarchyDescriptor = type { i32, i32, i32, i32 } |
| 20 |
%rtti.BaseClassDescriptor = type { i32, i32, i32, i32, i32, i32, i32 } |
| 21 |
%rtti.TypeDescriptor10 = type { ptr, ptr, [11 x i8] } |
| 22 |
|
| 23 |
$"\01??0Derived@@QEAA@XZ" = comdat any |
| 24 |
|
| 25 |
$"\01??0Base@@QEAA@XZ" = comdat any |
| 26 |
|
| 27 |
$"\01?virt_method@Derived@@UEBAHXZ" = comdat any |
| 28 |
|
| 29 |
$"\01??_7Derived@@6B@" = comdat largest |
| 30 |
|
| 31 |
$"\01??_R4Derived@@6B@" = comdat any |
| 32 |
|
| 33 |
$"\01??_R0?AUDerived@@@8" = comdat any |
| 34 |
|
| 35 |
$"\01??_R3Derived@@8" = comdat any |
| 36 |
|
| 37 |
$"\01??_R2Derived@@8" = comdat any |
| 38 |
|
| 39 |
$"\01??_R1A@?0A@EA@Derived@@8" = comdat any |
| 40 |
|
| 41 |
$"\01??_R1A@?0A@EA@Base@@8" = comdat any |
| 42 |
|
| 43 |
$"\01??_R0?AUBase@@@8" = comdat any |
| 44 |
|
| 45 |
$"\01??_R3Base@@8" = comdat any |
| 46 |
|
| 47 |
$"\01??_R2Base@@8" = comdat any |
| 48 |
|
| 49 |
$"\01??_7Base@@6B@" = comdat largest |
| 50 |
|
| 51 |
$"\01??_R4Base@@6B@" = comdat any |
| 52 |
|
| 53 |
@"\01?D@@3UDerived@@A" = global %struct.Derived zeroinitializer, align 8 |
| 54 |
@0 = private unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ptr @"\01??_R4Derived@@6B@", ptr @"\01?virt_method@Derived@@UEBAHXZ"] }, comdat($"\01??_7Derived@@6B@") |
| 55 |
@"\01??_R4Derived@@6B@" = linkonce_odr constant %rtti.CompleteObjectLocator { i32 1, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R0?AUDerived@@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R3Derived@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R4Derived@@6B@" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, comdat |
| 56 |
@"\01??_7type_info@@6B@" = external constant ptr |
| 57 |
@"\01??_R0?AUDerived@@@8" = linkonce_odr global %rtti.TypeDescriptor13 { ptr @"\01??_7type_info@@6B@", ptr null, [14 x i8] c".?AUDerived@@\00" }, comdat |
| 58 |
@__ImageBase = external constant i8 |
| 59 |
@"\01??_R3Derived@@8" = linkonce_odr constant %rtti.ClassHierarchyDescriptor { i32 0, i32 0, i32 2, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R2Derived@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, comdat |
| 60 |
@"\01??_R2Derived@@8" = linkonce_odr constant [3 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R1A@?0A@EA@Derived@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R1A@?0A@EA@Base@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0], comdat |
| 61 |
@"\01??_R1A@?0A@EA@Derived@@8" = linkonce_odr constant %rtti.BaseClassDescriptor { i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R0?AUDerived@@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 1, i32 0, i32 -1, i32 0, i32 64, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R3Derived@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, comdat |
| 62 |
@"\01??_R1A@?0A@EA@Base@@8" = linkonce_odr constant %rtti.BaseClassDescriptor { i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R0?AUBase@@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0, i32 0, i32 -1, i32 0, i32 64, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R3Base@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, comdat |
| 63 |
@"\01??_R0?AUBase@@@8" = linkonce_odr global %rtti.TypeDescriptor10 { ptr @"\01??_7type_info@@6B@", ptr null, [11 x i8] c".?AUBase@@\00" }, comdat |
| 64 |
@"\01??_R3Base@@8" = linkonce_odr constant %rtti.ClassHierarchyDescriptor { i32 0, i32 0, i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R2Base@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, comdat |
| 65 |
@"\01??_R2Base@@8" = linkonce_odr constant [2 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R1A@?0A@EA@Base@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0], comdat |
| 66 |
@1 = private unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ptr @"\01??_R4Base@@6B@", ptr @_purecall] }, comdat($"\01??_7Base@@6B@") |
| 67 |
@"\01??_R4Base@@6B@" = linkonce_odr constant %rtti.CompleteObjectLocator { i32 1, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R0?AUBase@@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R3Base@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R4Base@@6B@" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, comdat |
| 68 |
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_cfguard.cpp, ptr null }] |
| 69 |
|
| 70 |
@"\01??_7Derived@@6B@" = unnamed_addr alias ptr, getelementptr inbounds ({ [2 x ptr] }, ptr @0, i32 0, i32 0, i32 1) |
| 71 |
@"\01??_7Base@@6B@" = unnamed_addr alias ptr, getelementptr inbounds ({ [2 x ptr] }, ptr @1, i32 0, i32 0, i32 1) |
| 72 |
|
| 73 |
; Function Attrs: noinline nounwind |
| 74 |
define internal void @"\01??__ED@@YAXXZ"() #0 { |
| 75 |
entry: |
| 76 |
%call = call ptr @"\01??0Derived@@QEAA@XZ"(ptr @"\01?D@@3UDerived@@A") #2 |
| 77 |
ret void |
| 78 |
} |
| 79 |
|
| 80 |
; Function Attrs: noinline nounwind optnone |
| 81 |
define linkonce_odr ptr @"\01??0Derived@@QEAA@XZ"(ptr returned %this) unnamed_addr #1 comdat align 2 { |
| 82 |
entry: |
| 83 |
%this.addr = alloca ptr, align 8 |
| 84 |
store ptr %this, ptr %this.addr, align 8 |
| 85 |
%this1 = load ptr, ptr %this.addr, align 8 |
| 86 |
%0 = bitcast ptr %this1 to ptr |
| 87 |
%call = call ptr @"\01??0Base@@QEAA@XZ"(ptr %0) #2 |
| 88 |
%1 = bitcast ptr %this1 to ptr |
| 89 |
store ptr @"\01??_7Derived@@6B@", ptr %1, align 8 |
| 90 |
ret ptr %this1 |
| 91 |
} |
| 92 |
|
| 93 |
; Function Attrs: noinline nounwind optnone |
| 94 |
define void @"\01?address_taken@@YAXXZ"() #1 { |
| 95 |
entry: |
| 96 |
ret void |
| 97 |
} |
| 98 |
|
| 99 |
; Function Attrs: noinline nounwind optnone |
| 100 |
define ptr @"\01?foo@@YAP6AXXZPEAUBase@@@Z"(ptr %B) #1 { |
| 101 |
entry: |
| 102 |
%retval = alloca ptr, align 8 |
| 103 |
%B.addr = alloca ptr, align 8 |
| 104 |
store ptr %B, ptr %B.addr, align 8 |
| 105 |
%0 = load ptr, ptr %B.addr, align 8 |
| 106 |
%1 = bitcast ptr %0 to ptr |
| 107 |
%vtable = load ptr, ptr %1, align 8 |
| 108 |
%vfn = getelementptr inbounds ptr, ptr %vtable, i64 0 |
| 109 |
%2 = load ptr, ptr %vfn, align 8 |
| 110 |
%call = call i32 %2(ptr %0) |
| 111 |
%tobool = icmp ne i32 %call, 0 |
| 112 |
br i1 %tobool, label %if.then, label %if.end |
| 113 |
|
| 114 |
if.then: ; preds = %entry |
| 115 |
store ptr @"\01?address_taken@@YAXXZ", ptr %retval, align 8 |
| 116 |
br label %return |
| 117 |
|
| 118 |
if.end: ; preds = %entry |
| 119 |
store ptr null, ptr %retval, align 8 |
| 120 |
br label %return |
| 121 |
|
| 122 |
return: ; preds = %if.end, %if.then |
| 123 |
%3 = load ptr, ptr %retval, align 8 |
| 124 |
ret ptr %3 |
| 125 |
} |
| 126 |
|
| 127 |
; Function Attrs: noinline nounwind optnone |
| 128 |
define linkonce_odr ptr @"\01??0Base@@QEAA@XZ"(ptr returned %this) unnamed_addr #1 comdat align 2 { |
| 129 |
entry: |
| 130 |
%this.addr = alloca ptr, align 8 |
| 131 |
store ptr %this, ptr %this.addr, align 8 |
| 132 |
%this1 = load ptr, ptr %this.addr, align 8 |
| 133 |
%0 = bitcast ptr %this1 to ptr |
| 134 |
store ptr @"\01??_7Base@@6B@", ptr %0, align 8 |
| 135 |
ret ptr %this1 |
| 136 |
} |
| 137 |
|
| 138 |
; Function Attrs: noinline nounwind optnone |
| 139 |
define linkonce_odr i32 @"\01?virt_method@Derived@@UEBAHXZ"(ptr %this) unnamed_addr #1 comdat align 2 { |
| 140 |
entry: |
| 141 |
%this.addr = alloca ptr, align 8 |
| 142 |
store ptr %this, ptr %this.addr, align 8 |
| 143 |
%this1 = load ptr, ptr %this.addr, align 8 |
| 144 |
ret i32 42 |
| 145 |
} |
| 146 |
|
| 147 |
declare dllimport void @_purecall() unnamed_addr |
| 148 |
|
| 149 |
; Function Attrs: noinline nounwind |
| 150 |
define internal void @_GLOBAL__sub_I_cfguard.cpp() #0 { |
| 151 |
entry: |
| 152 |
call void @"\01??__ED@@YAXXZ"() |
| 153 |
ret void |
| 154 |
} |
| 155 |
|
| 156 |
attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 157 |
attributes #1 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 158 |
attributes #2 = { nounwind } |
| 159 |
|
| 160 |
!llvm.module.flags = !{!0, !1} |
| 161 |
!llvm.ident = !{!2} |
| 162 |
|
| 163 |
!0 = !{i32 2, !"cfguard", i32 1} |
| 164 |
!1 = !{i32 1, !"wchar_size", i32 2} |
| 165 |
!2 = !{!"clang version 6.0.0 "} |