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