Debian Codegraph @

llvm/test/CodeGen/WinCFGuard/cfguard-mingw.ll

raw
1 ; RUN: llc < %s -mtriple=x86_64-w64-windows-gnu | FileCheck %s
2 ; Control Flow Guard is currently only available on Windows
3
4 ; This file was generated from the following source, using this command line:
5 ; clang++ -target x86_64-w64-windows-gnu cfguard-mingw.cpp -S -emit-llvm -o cfguard-mingw.ll -O -Xclang -cfguard
6 ;
7 ;-------------------------------------------------------------------------------
8 ; class __attribute__((dllexport)) Base {
9 ; public:
10 ; __attribute__((dllexport)) Base() = default;
11 ; __attribute__((dllexport)) virtual ~Base() = default;
12 ; __attribute__((dllexport)) virtual int calc() const {
13 ; return m_field * 2;
14 ; }
15 ; int m_field{0};
16 ; };
17 ;
18 ; class __attribute__((dllexport)) Derived : public Base {
19 ; public:
20 ; __attribute__((dllexport)) Derived() = default;
21 ; __attribute__((dllexport)) ~Derived() override = default;
22 ; __attribute__((dllexport)) int calc() const override {
23 ; return m_field * 2 + m_newfield;
24 ; }
25 ; int m_newfield{0};
26 ; };
27 ;
28 ; __attribute((noinline)) void address_taken() {}
29 ; __attribute((noinline)) void address_not_taken() {}
30 ;
31 ; using fn_t = void (*)();
32 ; __attribute__((dllexport)) fn_t get_address() {
33 ; address_not_taken();
34 ; return &address_taken;
35 ; }
36 ;-------------------------------------------------------------------------------
37
38 ; CHECK: @feat.00 = 2048
39
40 ; CHECK: .section .gfids$y
41 ; CHECK: .symidx _ZNK7Derived4calcEv
42 ; CHECK: .symidx _Z13address_takenv
43
44 ; ModuleID = 'cfguard-mingw.cpp'
45 source_filename = "cfguard-mingw.cpp"
46 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
47 target triple = "x86_64-w64-windows-gnu"
48
49 %class.Base = type <{ ptr, i32, [4 x i8] }>
50 %class.Derived = type { %class.Base.base, i32 }
51 %class.Base.base = type <{ ptr, i32 }>
52
53 $_ZN4BaseC2Ev = comdat any
54
55 $_ZN4BaseC1Ev = comdat any
56
57 $_ZNK4Base4calcEv = comdat any
58
59 $_ZN4BaseD2Ev = comdat any
60
61 $_ZN4BaseD1Ev = comdat any
62
63 $_ZN4BaseD0Ev = comdat any
64
65 $_ZN7DerivedC2Ev = comdat any
66
67 $_ZN7DerivedC1Ev = comdat any
68
69 $_ZNK7Derived4calcEv = comdat any
70
71 $_ZN7DerivedD2Ev = comdat any
72
73 $_ZN7DerivedD1Ev = comdat any
74
75 $_ZN7DerivedD0Ev = comdat any
76
77 $_ZTV4Base = comdat any
78
79 $_ZTV7Derived = comdat any
80
81 $_ZTS4Base = comdat any
82
83 $_ZTI4Base = comdat any
84
85 $_ZTS7Derived = comdat any
86
87 $_ZTI7Derived = comdat any
88
89 @_ZTV4Base = weak_odr dso_local dllexport unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI4Base, ptr @_ZN4BaseD1Ev, ptr @_ZN4BaseD0Ev, ptr @_ZNK4Base4calcEv] }, comdat, align 8
90 @_ZTV7Derived = weak_odr dso_local dllexport unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI7Derived, ptr @_ZN7DerivedD1Ev, ptr @_ZN7DerivedD0Ev, ptr @_ZNK7Derived4calcEv] }, comdat, align 8
91 @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
92 @_ZTS4Base = linkonce_odr dso_local constant [6 x i8] c"4Base\00", comdat, align 1
93 @_ZTI4Base = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS4Base }, comdat, align 8
94 @_ZTVN10__cxxabiv120__si_class_type_infoE = external global ptr
95 @_ZTS7Derived = linkonce_odr dso_local constant [9 x i8] c"7Derived\00", comdat, align 1
96 @_ZTI7Derived = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTS7Derived, ptr @_ZTI4Base }, comdat, align 8
97
98 ; Function Attrs: nounwind uwtable
99 define weak_odr dso_local dllexport void @_ZN4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {
100 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV4Base, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5
101 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1
102 store i32 0, ptr %2, align 8, !tbaa !8
103 ret void
104 }
105
106 ; Function Attrs: nounwind uwtable
107 define weak_odr dso_local dllexport void @_ZN4BaseC1Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {
108 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV4Base, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5
109 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1
110 store i32 0, ptr %2, align 8, !tbaa !8
111 ret void
112 }
113
114 ; Function Attrs: mustprogress nounwind uwtable
115 define weak_odr dso_local dllexport noundef i32 @_ZNK4Base4calcEv(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #1 comdat align 2 {
116 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1
117 %3 = load i32, ptr %2, align 8, !tbaa !8
118 %4 = shl nsw i32 %3, 1
119 ret i32 %4
120 }
121
122 ; Function Attrs: nounwind uwtable
123 define weak_odr dso_local dllexport void @_ZN4BaseD2Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {
124 ret void
125 }
126
127 ; Function Attrs: nounwind uwtable
128 define weak_odr dso_local dllexport void @_ZN4BaseD1Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {
129 ret void
130 }
131
132 ; Function Attrs: nounwind uwtable
133 define weak_odr dso_local dllexport void @_ZN4BaseD0Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {
134 tail call void @_ZdlPv(ptr noundef nonnull %0) #5
135 ret void
136 }
137
138 ; Function Attrs: nobuiltin nounwind
139 declare dso_local void @_ZdlPv(ptr noundef) local_unnamed_addr #2
140
141 ; Function Attrs: nounwind uwtable
142 define weak_odr dso_local dllexport void @_ZN7DerivedC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {
143 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV4Base, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5
144 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1
145 store i32 0, ptr %2, align 8, !tbaa !8
146 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV7Derived, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5
147 %3 = getelementptr inbounds %class.Derived, ptr %0, i64 0, i32 1
148 store i32 0, ptr %3, align 4, !tbaa !12
149 ret void
150 }
151
152 ; Function Attrs: nounwind uwtable
153 define weak_odr dso_local dllexport void @_ZN7DerivedC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {
154 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV4Base, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5
155 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1
156 store i32 0, ptr %2, align 8, !tbaa !8
157 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV7Derived, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5
158 %3 = getelementptr inbounds %class.Derived, ptr %0, i64 0, i32 1
159 store i32 0, ptr %3, align 4, !tbaa !12
160 ret void
161 }
162
163 ; Function Attrs: mustprogress nounwind uwtable
164 define weak_odr dso_local dllexport noundef i32 @_ZNK7Derived4calcEv(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #1 comdat align 2 {
165 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1
166 %3 = load i32, ptr %2, align 8, !tbaa !8
167 %4 = shl nsw i32 %3, 1
168 %5 = getelementptr inbounds %class.Derived, ptr %0, i64 0, i32 1
169 %6 = load i32, ptr %5, align 4, !tbaa !12
170 %7 = add nsw i32 %4, %6
171 ret i32 %7
172 }
173
174 ; Function Attrs: nounwind uwtable
175 define weak_odr dso_local dllexport void @_ZN7DerivedD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {
176 ret void
177 }
178
179 ; Function Attrs: nounwind uwtable
180 define weak_odr dso_local dllexport void @_ZN7DerivedD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {
181 ret void
182 }
183
184 ; Function Attrs: nounwind uwtable
185 define weak_odr dso_local dllexport void @_ZN7DerivedD0Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {
186 tail call void @_ZdlPv(ptr noundef nonnull %0) #5
187 ret void
188 }
189
190 ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable
191 define dso_local void @_Z13address_takenv() #3 {
192 ret void
193 }
194
195 ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable
196 define dso_local void @_Z17address_not_takenv() local_unnamed_addr #3 {
197 ret void
198 }
199
200 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
201 define dso_local dllexport noundef nonnull ptr @_Z11get_addressv() local_unnamed_addr #4 {
202 ret ptr @_Z13address_takenv
203 }
204
205 attributes #0 = { nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
206 attributes #1 = { mustprogress nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
207 attributes #2 = { nobuiltin nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
208 attributes #3 = { mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
209 attributes #4 = { mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
210 attributes #5 = { builtin nounwind }
211
212 !llvm.module.flags = !{!0, !1, !2, !3}
213 !llvm.ident = !{!4}
214
215 !0 = !{i32 2, !"cfguard", i32 2}
216 !1 = !{i32 1, !"wchar_size", i32 2}
217 !2 = !{i32 8, !"PIC Level", i32 2}
218 !3 = !{i32 7, !"uwtable", i32 2}
219 !4 = !{!"clang version 16.0.0"}
220 !5 = !{!6, !6, i64 0}
221 !6 = !{!"vtable pointer", !7, i64 0}
222 !7 = !{!"Simple C++ TBAA"}
223 !8 = !{!9, !10, i64 8}
224 !9 = !{!"_ZTS4Base", !10, i64 8}
225 !10 = !{!"int", !11, i64 0}
226 !11 = !{!"omnipotent char", !7, i64 0}
227 !12 = !{!13, !10, i64 12}
228 !13 = !{!"_ZTS7Derived", !9, i64 0, !10, i64 12}