1 ; RUN: llc < %s -mtriple=x86_64-w64-windows-gnu | FileCheck %s
2 ; Control Flow Guard is currently only available on Windows
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
7 ;-------------------------------------------------------------------------------
8 ; class __attribute__((dllexport)) Base {
10 ; __attribute__((dllexport)) Base() = default;
11 ; __attribute__((dllexport)) virtual ~Base() = default;
12 ; __attribute__((dllexport)) virtual int calc() const {
18 ; class __attribute__((dllexport)) Derived : public Base {
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;
28 ; __attribute((noinline)) void address_taken() {}
29 ; __attribute((noinline)) void address_not_taken() {}
31 ; using fn_t = void (*)();
32 ; __attribute__((dllexport)) fn_t get_address() {
33 ; address_not_taken();
34 ; return &address_taken;
36 ;-------------------------------------------------------------------------------
38 ; CHECK: .set @feat.00, 2048
40 ; CHECK: .section .gfids$y
41 ; CHECK: .symidx _ZNK7Derived4calcEv
42 ; CHECK: .symidx _Z13address_takenv
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"
49 %class.Base = type <{ ptr, i32, [4 x i8] }>
50 %class.Derived = type { %class.Base.base, i32 }
51 %class.Base.base = type <{ ptr, i32 }>
53 $_ZN4BaseC2Ev = comdat any
55 $_ZN4BaseC1Ev = comdat any
57 $_ZNK4Base4calcEv = comdat any
59 $_ZN4BaseD2Ev = comdat any
61 $_ZN4BaseD1Ev = comdat any
63 $_ZN4BaseD0Ev = comdat any
65 $_ZN7DerivedC2Ev = comdat any
67 $_ZN7DerivedC1Ev = comdat any
69 $_ZNK7Derived4calcEv = comdat any
71 $_ZN7DerivedD2Ev = comdat any
73 $_ZN7DerivedD1Ev = comdat any
75 $_ZN7DerivedD0Ev = comdat any
77 $_ZTV4Base = comdat any
79 $_ZTV7Derived = comdat any
81 $_ZTS4Base = comdat any
83 $_ZTI4Base = comdat any
85 $_ZTS7Derived = comdat any
87 $_ZTI7Derived = comdat any
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
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
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
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
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 {
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 {
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
138 ; Function Attrs: nobuiltin nounwind
139 declare dso_local void @_ZdlPv(ptr noundef) local_unnamed_addr #2
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
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
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
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 {
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 {
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
190 ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable
191 define dso_local void @_Z13address_takenv() #3 {
195 ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable
196 define dso_local void @_Z17address_not_takenv() local_unnamed_addr #3 {
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
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 }
212 !llvm.module.flags = !{!0, !1, !2, !3}
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}