1 // RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s 2 // RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s 3 4 struct A { 5 A(); 6 virtual void f(); 7 }; 8 9 A::A() {} 10 void A::f() {} 11 12 void caller(A* a) { 13 a->f(); 14 } 15 16 namespace { 17 struct B { 18 virtual void f(); 19 }; 20 21 void B::f() {} 22 } // namespace 23 24 void g() { 25 B b; 26 b.f(); 27 } 28 29 // MS: @[[B_VTABLE:.*]] = private unnamed_addr constant [2 x i8*] {{.*}}@"\01??_R4B@?A@@6B@"{{.*}}@"\01?f@B@?A@@UEAAXXZ" 30 31 // CHECK: %[[VT:.*]] = load void (%struct.A*)**, void (%struct.A*)*** 32 // CHECK: %[[VT2:.*]] = bitcast {{.*}}%[[VT]] to i8*, !nosanitize 33 // ITANIUM: %[[TEST:.*]] = call i1 @llvm.type.test(i8* %[[VT2]], metadata !"_ZTS1A"), !nosanitize 34 // MS: %[[TEST:.*]] = call i1 @llvm.type.test(i8* %[[VT2]], metadata !"?AUA@@"), !nosanitize 35 // CHECK: br i1 %[[TEST]], label %[[CONT:.*]], label %[[SLOW:.*]], {{.*}} !nosanitize 36 // CHECK: [[SLOW]] 37 // ITANIUM: call void @__cfi_slowpath_diag(i64 7004155349499253778, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize 38 // MS: call void @__cfi_slowpath_diag(i64 -8005289897957287421, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize 39 // CHECK: br label %[[CONT]], !nosanitize 40 // CHECK: [[CONT]] 41 // CHECK: call void %{{.*}}(%struct.A* %{{.*}}) 42 43 // No hash-based bit set entry for (anonymous namespace)::B 44 // ITANIUM-NOT: !{i64 {{.*}}, [3 x i8*]* @_ZTVN12_GLOBAL__N_11BE, 45 // MS-NOT: !{i64 {{.*}}, [2 x i8*]* @[[B_VTABLE]], 46