2016-04-29 01:09:37 +08:00
|
|
|
// 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
|
|
|
|
// 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
|
2015-12-16 07:00:20 +08:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
A();
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
A::A() {}
|
|
|
|
void A::f() {}
|
|
|
|
|
|
|
|
void caller(A* a) {
|
|
|
|
a->f();
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
struct B {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
void B::f() {}
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
B b;
|
|
|
|
b.f();
|
|
|
|
}
|
|
|
|
|
[MS] Mangle a hash of the main file path into anonymous namespaces
Summary:
This is needed to avoid conflicts in mangled names for codeview types in
anonymous namespaces. In CodeView, types refer to each other typically
through forward declarations, which contain mangled names. These names
have to be unique, otherwise the debugger will look up the mangled name
and find the wrong definition.
Furthermore, ThinLTO will deduplicate the types, and debug info
verification can fail when the types have the wrong sizes. This is
PR38608.
Fixes PR38609.
Reviewers: majnemer, inglorion, hans
Subscribers: mehdi_amini, aprantl, JDevlieghere, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D50877
llvm-svn: 340079
2018-08-18 04:59:27 +08:00
|
|
|
// MS: @[[B_VTABLE:.*]] = private unnamed_addr constant { [2 x i8*] } {{.*}}@"??_R4B@?A0x{{[^@]*}}@@6B@"{{.*}}@"?f@B@?A0x{{[^@]*}}@@UEAAXXZ"
|
2015-12-16 07:00:20 +08:00
|
|
|
|
|
|
|
// CHECK: %[[VT:.*]] = load void (%struct.A*)**, void (%struct.A*)***
|
|
|
|
// CHECK: %[[VT2:.*]] = bitcast {{.*}}%[[VT]] to i8*, !nosanitize
|
2016-06-25 05:21:46 +08:00
|
|
|
// ITANIUM: %[[TEST:.*]] = call i1 @llvm.type.test(i8* %[[VT2]], metadata !"_ZTS1A"), !nosanitize
|
|
|
|
// MS: %[[TEST:.*]] = call i1 @llvm.type.test(i8* %[[VT2]], metadata !"?AUA@@"), !nosanitize
|
2015-12-16 07:00:20 +08:00
|
|
|
// CHECK: br i1 %[[TEST]], label %[[CONT:.*]], label %[[SLOW:.*]], {{.*}} !nosanitize
|
2015-12-16 07:49:51 +08:00
|
|
|
// CHECK: [[SLOW]]
|
2016-01-26 07:34:52 +08:00
|
|
|
// ITANIUM: call void @__cfi_slowpath_diag(i64 7004155349499253778, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
|
|
|
|
// MS: call void @__cfi_slowpath_diag(i64 -8005289897957287421, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
|
2015-12-16 07:00:20 +08:00
|
|
|
// CHECK: br label %[[CONT]], !nosanitize
|
2015-12-16 07:49:51 +08:00
|
|
|
// CHECK: [[CONT]]
|
2020-11-17 07:04:55 +08:00
|
|
|
// CHECK: call void %{{.*}}(%struct.A* {{[^,]*}} %{{.*}})
|
2015-12-16 07:00:20 +08:00
|
|
|
|
|
|
|
// No hash-based bit set entry for (anonymous namespace)::B
|
|
|
|
// ITANIUM-NOT: !{i64 {{.*}}, [3 x i8*]* @_ZTVN12_GLOBAL__N_11BE,
|
|
|
|
// MS-NOT: !{i64 {{.*}}, [2 x i8*]* @[[B_VTABLE]],
|