229 lines · plain
1; RUN: llc < %s -mtriple=x86_64-w64-windows-gnu | FileCheck %s2; Control Flow Guard is currently only available on Windows3 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 -cfguard6;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 = 204839 40; CHECK: .section .gfids$y41; CHECK: .symidx _ZNK7Derived4calcEv42; CHECK: .symidx _Z13address_takenv43 44; ModuleID = 'cfguard-mingw.cpp'45source_filename = "cfguard-mingw.cpp"46target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"47target 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 any54 55$_ZN4BaseC1Ev = comdat any56 57$_ZNK4Base4calcEv = comdat any58 59$_ZN4BaseD2Ev = comdat any60 61$_ZN4BaseD1Ev = comdat any62 63$_ZN4BaseD0Ev = comdat any64 65$_ZN7DerivedC2Ev = comdat any66 67$_ZN7DerivedC1Ev = comdat any68 69$_ZNK7Derived4calcEv = comdat any70 71$_ZN7DerivedD2Ev = comdat any72 73$_ZN7DerivedD1Ev = comdat any74 75$_ZN7DerivedD0Ev = comdat any76 77$_ZTV4Base = comdat any78 79$_ZTV7Derived = comdat any80 81$_ZTS4Base = comdat any82 83$_ZTI4Base = comdat any84 85$_ZTS7Derived = comdat any86 87$_ZTI7Derived = comdat any88 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 890@_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 891@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr92@_ZTS4Base = linkonce_odr dso_local constant [6 x i8] c"4Base\00", comdat, align 193@_ZTI4Base = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS4Base }, comdat, align 894@_ZTVN10__cxxabiv120__si_class_type_infoE = external global ptr95@_ZTS7Derived = linkonce_odr dso_local constant [9 x i8] c"7Derived\00", comdat, align 196@_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 897 98; Function Attrs: nounwind uwtable99define 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 !5101 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1102 store i32 0, ptr %2, align 8, !tbaa !8103 ret void104}105 106; Function Attrs: nounwind uwtable107define 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 !5109 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1110 store i32 0, ptr %2, align 8, !tbaa !8111 ret void112}113 114; Function Attrs: mustprogress nounwind uwtable115define 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 1117 %3 = load i32, ptr %2, align 8, !tbaa !8118 %4 = shl nsw i32 %3, 1119 ret i32 %4120}121 122; Function Attrs: nounwind uwtable123define weak_odr dso_local dllexport void @_ZN4BaseD2Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {124 ret void125}126 127; Function Attrs: nounwind uwtable128define weak_odr dso_local dllexport void @_ZN4BaseD1Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #0 comdat align 2 {129 ret void130}131 132; Function Attrs: nounwind uwtable133define 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) #5135 ret void136}137 138; Function Attrs: nobuiltin nounwind139declare dso_local void @_ZdlPv(ptr noundef) local_unnamed_addr #2140 141; Function Attrs: nounwind uwtable142define 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 !5144 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1145 store i32 0, ptr %2, align 8, !tbaa !8146 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV7Derived, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5147 %3 = getelementptr inbounds %class.Derived, ptr %0, i64 0, i32 1148 store i32 0, ptr %3, align 4, !tbaa !12149 ret void150}151 152; Function Attrs: nounwind uwtable153define 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 !5155 %2 = getelementptr inbounds %class.Base, ptr %0, i64 0, i32 1156 store i32 0, ptr %2, align 8, !tbaa !8157 store ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV7Derived, i64 0, i32 0, i64 2), ptr %0, align 8, !tbaa !5158 %3 = getelementptr inbounds %class.Derived, ptr %0, i64 0, i32 1159 store i32 0, ptr %3, align 4, !tbaa !12160 ret void161}162 163; Function Attrs: mustprogress nounwind uwtable164define 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 1166 %3 = load i32, ptr %2, align 8, !tbaa !8167 %4 = shl nsw i32 %3, 1168 %5 = getelementptr inbounds %class.Derived, ptr %0, i64 0, i32 1169 %6 = load i32, ptr %5, align 4, !tbaa !12170 %7 = add nsw i32 %4, %6171 ret i32 %7172}173 174; Function Attrs: nounwind uwtable175define weak_odr dso_local dllexport void @_ZN7DerivedD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {176 ret void177}178 179; Function Attrs: nounwind uwtable180define weak_odr dso_local dllexport void @_ZN7DerivedD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 comdat align 2 {181 ret void182}183 184; Function Attrs: nounwind uwtable185define 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) #5187 ret void188}189 190; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable191define dso_local void @_Z13address_takenv() #3 {192 ret void193}194 195; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readnone willreturn uwtable196define dso_local void @_Z17address_not_takenv() local_unnamed_addr #3 {197 ret void198}199 200; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable201define dso_local dllexport noundef nonnull ptr @_Z11get_addressv() local_unnamed_addr #4 {202 ret ptr @_Z13address_takenv203}204 205attributes #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" }206attributes #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" }207attributes #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" }208attributes #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" }209attributes #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" }210attributes #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}229