summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-07-31 20:45:14 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-07-31 20:45:14 +0000
commit8867b216dc9635a922c0fe0766c76f60c2266c60 (patch)
treef1800f9a8bcba81ee5973f92c8a8313c86e8e45a /clang/test
parentbcd204b47887e159981b89ab65c29cd939b77d6c (diff)
downloadbcm5719-llvm-8867b216dc9635a922c0fe0766c76f60c2266c60.tar.gz
bcm5719-llvm-8867b216dc9635a922c0fe0766c76f60c2266c60.zip
Fix logic for generating llvm.type.test()s
CodeGenFunction::EmitTypeMetadataCodeForVCall() could output an llvm.assume(llvm.type.test())when CFI was enabled, optimizing out the vcall check. This case was only reached when: 1) CFI-vcall was enabled, 2) -fwhole-program-tables was specified, and 3) -fno-sanitize-trap=cfi-vcall was specified. Patch by Vlad Tsyrklevich! Differential Revision: https://reviews.llvm.org/D36013 llvm-svn: 309622
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp b/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp
new file mode 100644
index 00000000000..dbfe558065a
--- /dev/null
+++ b/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp
@@ -0,0 +1,15 @@
+// Only output llvm.assume(llvm.type.test()) if cfi-vcall is disabled and whole-program-vtables is enabled
+// RUN: %clang_cc1 -fvisibility hidden -fsanitize=cfi-vcall -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CFI %s
+// RUN: %clang_cc1 -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOCFI %s
+
+struct S1 {
+ virtual void f();
+};
+
+// CHECK: define{{.*}}s1f
+// CHECK: llvm.type.test
+// CFI-NOT: llvm.assume
+// NOCFI: llvm.assume
+void s1f(S1 *s1) {
+ s1->f();
+}
OpenPOWER on IntegriCloud