diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-01-16 00:31:22 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-01-16 00:31:22 +0000 |
commit | dc13453128d5d1d60b3b3583337c91a095fa90e7 (patch) | |
tree | 6e3ff34b49a569003f01c59bc4c0f46e7b314748 /clang/test/CodeGenCXX/cfi-stats.cpp | |
parent | f0f5e870831fc4ac78c18f6fb786a9bea37e8aa9 (diff) | |
download | bcm5719-llvm-dc13453128d5d1d60b3b3583337c91a095fa90e7.tar.gz bcm5719-llvm-dc13453128d5d1d60b3b3583337c91a095fa90e7.zip |
Introduce -fsanitize-stats flag.
This is part of a new statistics gathering feature for the sanitizers.
See clang/docs/SanitizerStats.rst for further info and docs.
Differential Revision: http://reviews.llvm.org/D16175
llvm-svn: 257971
Diffstat (limited to 'clang/test/CodeGenCXX/cfi-stats.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/cfi-stats.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cfi-stats.cpp b/clang/test/CodeGenCXX/cfi-stats.cpp new file mode 100644 index 00000000000..49c067784c4 --- /dev/null +++ b/clang/test/CodeGenCXX/cfi-stats.cpp @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-stats -emit-llvm -o - %s | FileCheck --check-prefix=CHECK %s + +// CHECK: [[STATS:@[^ ]*]] = internal global { i8*, i32, [5 x [2 x i8*]] } { i8* null, i32 5, [5 x [2 x i8*]] +// CHECK: {{\[\[}}2 x i8*] zeroinitializer, +// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 2305843009213693952 to i8*)], +// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 4611686018427387904 to i8*)], +// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 6917529027641081856 to i8*)], +// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 -9223372036854775808 to i8*)]] } + +// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* [[CTOR:@[^ ]*]], i8* null }] + +struct A { + virtual void vf(); + void nvf(); +}; +struct B : A {}; + +// CHECK: @vcall +extern "C" void vcall(A *a) { + // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 0 + a->vf(); +} + +// CHECK: @nvcall +extern "C" void nvcall(A *a) { + // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 1 + a->nvf(); +} + +// CHECK: @dcast +extern "C" void dcast(A *a) { + // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 2 + static_cast<B *>(a); +} + +// CHECK: @ucast +extern "C" void ucast(void *a) { + // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 3 + reinterpret_cast<A *>(a); +} + +// CHECK: @icall +extern "C" void icall(void (*p)()) { + // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 4 + p(); +} + +// CHECK: define internal void [[CTOR]]() +// CHECK-NEXT: call void @__sanitizer_stat_init(i8* bitcast ({ i8*, i32, [5 x [2 x i8*]] }* [[STATS]] to i8*)) +// CHECK-NEXT: ret void |