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