aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-06-25 00:24:22 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-06-25 00:24:22 +0000
commitc79ad577fb6aa2a02c83c8787a9f2a41e80de2cc (patch)
treef27fe81d6b6e130a636a05c7694b79007db03a69
parent0ca0363d052425c5788aafeafe6030264c25cdb2 (diff)
downloadllvm-c79ad577fb6aa2a02c83c8787a9f2a41e80de2cc.zip
llvm-c79ad577fb6aa2a02c83c8787a9f2a41e80de2cc.tar.gz
llvm-c79ad577fb6aa2a02c83c8787a9f2a41e80de2cc.tar.bz2
cfi: Start testing CFI in both standalone and devirtualization modes.
Differential Revision: http://reviews.llvm.org/D21123 llvm-svn: 273758
-rw-r--r--compiler-rt/test/cfi/CMakeLists.txt15
-rw-r--r--compiler-rt/test/cfi/lit.cfg8
-rw-r--r--compiler-rt/test/cfi/lit.site.cfg.in2
-rw-r--r--compiler-rt/test/cfi/overwrite.cpp7
-rw-r--r--compiler-rt/test/cfi/stats.cpp3
-rw-r--r--compiler-rt/test/lit.common.cfg6
6 files changed, 34 insertions, 7 deletions
diff --git a/compiler-rt/test/cfi/CMakeLists.txt b/compiler-rt/test/cfi/CMakeLists.txt
index cbd9a3c..914fe08 100644
--- a/compiler-rt/test/cfi/CMakeLists.txt
+++ b/compiler-rt/test/cfi/CMakeLists.txt
@@ -1,6 +1,13 @@
+set(CFI_LIT_TEST_MODE Standalone)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ ${CMAKE_CURRENT_BINARY_DIR}/Standalone/lit.site.cfg
+ )
+
+set(CFI_LIT_TEST_MODE Devirt)
+configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Devirt/lit.site.cfg
)
set(CFI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
@@ -32,11 +39,13 @@ if(NOT COMPILER_RT_STANDALONE_BUILD)
endif()
add_lit_testsuite(check-cfi "Running the cfi regression tests"
- ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/Standalone
+ ${CMAKE_CURRENT_BINARY_DIR}/Devirt
DEPENDS ${CFI_TEST_DEPS})
add_lit_target(check-cfi-and-supported "Running the cfi regression tests"
- ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/Standalone
+ ${CMAKE_CURRENT_BINARY_DIR}/Devirt
PARAMS check_supported=1
DEPENDS ${CFI_TEST_DEPS})
diff --git a/compiler-rt/test/cfi/lit.cfg b/compiler-rt/test/cfi/lit.cfg
index 7e5fdc2..3c02506 100644
--- a/compiler-rt/test/cfi/lit.cfg
+++ b/compiler-rt/test/cfi/lit.cfg
@@ -11,6 +11,14 @@ config.substitutions.append((r"%clang ", ' '.join([config.clang]) + ' '))
config.substitutions.append((r"%clangxx ", clangxx + ' '))
if config.lto_supported:
clang_cfi = ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-flto -fsanitize=cfi '])
+
+ if config.cfi_lit_test_mode == "Devirt":
+ config.available_features.add('devirt')
+ clang_cfi += '-fwhole-program-vtables '
+ config.substitutions.append((r"%expect_crash_unless_devirt ", ""))
+ else:
+ config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash))
+
cxx = ' '.join(config.cxx_mode_flags) + ' '
diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi '
non_dso = '-fvisibility=hidden '
diff --git a/compiler-rt/test/cfi/lit.site.cfg.in b/compiler-rt/test/cfi/lit.site.cfg.in
index 866d3fa..87e5b51 100644
--- a/compiler-rt/test/cfi/lit.site.cfg.in
+++ b/compiler-rt/test/cfi/lit.site.cfg.in
@@ -1,4 +1,6 @@
@LIT_SITE_CFG_IN_HEADER@
+config.cfi_lit_test_mode = "@CFI_LIT_TEST_MODE@"
+
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
diff --git a/compiler-rt/test/cfi/overwrite.cpp b/compiler-rt/test/cfi/overwrite.cpp
index 90f995d..48c0a89 100644
--- a/compiler-rt/test/cfi/overwrite.cpp
+++ b/compiler-rt/test/cfi/overwrite.cpp
@@ -1,5 +1,5 @@
// RUN: %clangxx_cfi -o %t1 %s
-// RUN: %expect_crash %t1 2>&1 | FileCheck --check-prefix=CFI %s
+// RUN: %expect_crash_unless_devirt %t1 2>&1 | FileCheck --check-prefix=CFI %s
// RUN: %clangxx_cfi -DB32 -o %t2 %s
// RUN: %expect_crash %t2 2>&1 | FileCheck --check-prefix=CFI %s
@@ -55,7 +55,10 @@ int main() {
// CFI-DIAG-NEXT: note: invalid vtable
a->f();
- // CFI-NOT: {{^2$}}
+ // We don't check for the absence of a 2 here because under devirtualization
+ // our virtual call may be devirtualized and we will proceed with execution
+ // rather than crashing.
+
// NCFI: {{^2$}}
fprintf(stderr, "2\n");
}
diff --git a/compiler-rt/test/cfi/stats.cpp b/compiler-rt/test/cfi/stats.cpp
index eda11e1..566fcfb 100644
--- a/compiler-rt/test/cfi/stats.cpp
+++ b/compiler-rt/test/cfi/stats.cpp
@@ -2,6 +2,9 @@
// RUN: env SANITIZER_STATS_PATH=%t.stats %t
// RUN: sanstats %t.stats | FileCheck %s
+// FIXME: We currently emit the wrong debug info under devirtualization.
+// UNSUPPORTED: devirt
+
struct ABase {};
struct A : ABase {
diff --git a/compiler-rt/test/lit.common.cfg b/compiler-rt/test/lit.common.cfg
index c1a70ff..f19fde2 100644
--- a/compiler-rt/test/lit.common.cfg
+++ b/compiler-rt/test/lit.common.cfg
@@ -92,9 +92,11 @@ if config.host_os == 'Windows':
# does not crash but exits with a non-zero exit code. We ought to merge
# KillTheDoctor and not --crash to make the latter more useful and remove the
# need for this substitution.
- config.substitutions.append( ("%expect_crash ", "not KillTheDoctor ") )
+ config.expect_crash = "not KillTheDoctor "
else:
- config.substitutions.append( ("%expect_crash ", "not --crash ") )
+ config.expect_crash = "not --crash "
+
+config.substitutions.append( ("%expect_crash ", config.expect_crash) )
target_arch = getattr(config, 'target_arch', None)
if target_arch: