[compiler-rt] r273758 - cfi: Start testing CFI in both standalone and devirtualization modes.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 17:24:22 PDT 2016
Author: pcc
Date: Fri Jun 24 19:24:22 2016
New Revision: 273758
URL: http://llvm.org/viewvc/llvm-project?rev=273758&view=rev
Log:
cfi: Start testing CFI in both standalone and devirtualization modes.
Differential Revision: http://reviews.llvm.org/D21123
Modified:
compiler-rt/trunk/test/cfi/CMakeLists.txt
compiler-rt/trunk/test/cfi/lit.cfg
compiler-rt/trunk/test/cfi/lit.site.cfg.in
compiler-rt/trunk/test/cfi/overwrite.cpp
compiler-rt/trunk/test/cfi/stats.cpp
compiler-rt/trunk/test/lit.common.cfg
Modified: compiler-rt/trunk/test/cfi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/CMakeLists.txt?rev=273758&r1=273757&r2=273758&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/cfi/CMakeLists.txt Fri Jun 24 19:24:22 2016
@@ -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})
Modified: compiler-rt/trunk/test/cfi/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/lit.cfg?rev=273758&r1=273757&r2=273758&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/lit.cfg (original)
+++ compiler-rt/trunk/test/cfi/lit.cfg Fri Jun 24 19:24:22 2016
@@ -11,6 +11,14 @@ config.substitutions.append((r"%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 '
Modified: compiler-rt/trunk/test/cfi/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/lit.site.cfg.in?rev=273758&r1=273757&r2=273758&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/cfi/lit.site.cfg.in Fri Jun 24 19:24:22 2016
@@ -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")
Modified: compiler-rt/trunk/test/cfi/overwrite.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/overwrite.cpp?rev=273758&r1=273757&r2=273758&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/overwrite.cpp (original)
+++ compiler-rt/trunk/test/cfi/overwrite.cpp Fri Jun 24 19:24:22 2016
@@ -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");
}
Modified: compiler-rt/trunk/test/cfi/stats.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/stats.cpp?rev=273758&r1=273757&r2=273758&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/stats.cpp (original)
+++ compiler-rt/trunk/test/cfi/stats.cpp Fri Jun 24 19:24:22 2016
@@ -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 {
Modified: compiler-rt/trunk/test/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=273758&r1=273757&r2=273758&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lit.common.cfg Fri Jun 24 19:24:22 2016
@@ -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:
More information about the llvm-commits
mailing list