[compiler-rt] r301016 - [cfi] Run tests with and without lld and thinlto.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 11:11:23 PDT 2017


Author: eugenis
Date: Fri Apr 21 13:11:23 2017
New Revision: 301016

URL: http://llvm.org/viewvc/llvm-project?rev=301016&view=rev
Log:
[cfi] Run tests with and without lld and thinlto.

Run tests in all configurations:
(standalone, with devirtualization) * (gold, lld) * (lto, thinlto)

Modified:
    compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld.cc
    compiler-rt/trunk/test/cfi/CMakeLists.txt
    compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg
    compiler-rt/trunk/test/cfi/cross-dso/stats.cpp
    compiler-rt/trunk/test/cfi/icall/lit.local.cfg
    compiler-rt/trunk/test/cfi/lit.cfg
    compiler-rt/trunk/test/cfi/lit.site.cfg.in
    compiler-rt/trunk/test/lit.common.cfg
    compiler-rt/trunk/test/lit.common.configured.in
    compiler-rt/trunk/test/safestack/lit.cfg

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld.cc?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld.cc Fri Apr 21 13:11:23 2017
@@ -1,6 +1,6 @@
 // If we have LLD, see that things more or less work.
 //
-// REQUIRES: lld
+// REQUIRES: lld-available
 //
 // FIXME: Use -fuse-ld=lld after the old COFF linker is removed.
 // FIXME: Test will fail until we add flags for requesting dwarf or cv.

Modified: compiler-rt/trunk/test/cfi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/CMakeLists.txt?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/cfi/CMakeLists.txt Fri Apr 21 13:11:23 2017
@@ -1,14 +1,48 @@
-set(CFI_LIT_TEST_MODE Standalone)
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Standalone/lit.site.cfg
-  )
+set(CFI_TESTSUITES)
 
-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
-  )
+macro (add_cfi_test_suites lld thinlto)
+  set(suffix)
+  if (${lld})
+    set(suffix ${suffix}-lld)
+  endif()
+  if (${thinlto})
+    set(suffix ${suffix}-thinlto)
+  endif()
+
+  set(CFI_TEST_USE_LLD ${lld})
+  set(CFI_TEST_USE_THINLTO ${thinlto})
+
+  set(CFI_LIT_TEST_MODE Standalone)
+  set(CFI_TEST_CONFIG_SUFFIX -standalone${suffix})
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/Standalone${suffix}/lit.site.cfg
+    )
+  list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Standalone${suffix})
+
+  set(CFI_LIT_TEST_MODE Devirt)
+  set(CFI_TEST_CONFIG_SUFFIX -devirt${suffix})
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/Devirt${suffix}/lit.site.cfg
+    )
+  list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Devirt${suffix})
+endmacro()
+
+if (APPLE)
+  add_cfi_test_suites(False False)
+  add_cfi_test_suites(False True)
+elif (WINDOWS)
+  add_cfi_test_suites(True False)
+  add_cfi_test_suites(True True)
+else()
+  add_cfi_test_suites(False False)
+  add_cfi_test_suites(False True)
+  if (COMPILER_RT_HAS_LLD)
+    add_cfi_test_suites(True False)
+    add_cfi_test_suites(True True)
+  endif()
+endif()
 
 set(CFI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
 list(APPEND CFI_TEST_DEPS
@@ -34,7 +68,7 @@ if(NOT COMPILER_RT_STANDALONE_BUILD)
       LTO
     )
   endif()
-  if(WIN32 AND COMPILER_RT_HAS_LLD)
+  if(NOT APPLE AND COMPILER_RT_HAS_LLD)
     list(APPEND CFI_TEST_DEPS
       lld
     )
@@ -42,13 +76,11 @@ if(NOT COMPILER_RT_STANDALONE_BUILD)
 endif()
 
 add_lit_testsuite(check-cfi "Running the cfi regression tests"
-  ${CMAKE_CURRENT_BINARY_DIR}/Standalone
-  ${CMAKE_CURRENT_BINARY_DIR}/Devirt
+  ${CFI_TESTSUITES}
   DEPENDS ${CFI_TEST_DEPS})
 
 add_lit_target(check-cfi-and-supported "Running the cfi regression tests"
-  ${CMAKE_CURRENT_BINARY_DIR}/Standalone
-  ${CMAKE_CURRENT_BINARY_DIR}/Devirt
+  ${CFI_TESTSUITES}
   PARAMS check_supported=1
   DEPENDS ${CFI_TEST_DEPS})
 

Modified: compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg (original)
+++ compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg Fri Apr 21 13:11:23 2017
@@ -1,3 +1,6 @@
 # The cfi-icall checker is only supported on x86 and x86_64 for now.
 if config.root.host_arch not in ['x86', 'x86_64']:
   config.unsupported = True
+
+if config.root.use_thinlto:
+  config.unsupported = True

Modified: compiler-rt/trunk/test/cfi/cross-dso/stats.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/cross-dso/stats.cpp?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/cross-dso/stats.cpp (original)
+++ compiler-rt/trunk/test/cfi/cross-dso/stats.cpp Fri Apr 21 13:11:23 2017
@@ -3,6 +3,10 @@
 // RUN: env SANITIZER_STATS_PATH=%t.stats %t
 // RUN: sanstats %t.stats | FileCheck %s
 
+// CFI-icall is not implemented in thinlto mode => ".cfi" suffixes are missing
+// in sanstats output.
+// XFAIL: thinlto
+
 struct ABase {};
 
 struct A : ABase {

Modified: compiler-rt/trunk/test/cfi/icall/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/icall/lit.local.cfg?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/icall/lit.local.cfg (original)
+++ compiler-rt/trunk/test/cfi/icall/lit.local.cfg Fri Apr 21 13:11:23 2017
@@ -1,3 +1,6 @@
 # The cfi-icall checker is only supported on x86 and x86_64 for now.
 if config.root.host_arch not in ['x86', 'x86_64']:
   config.unsupported = True
+
+if config.use_thinlto:
+  config.unsupported = True

Modified: compiler-rt/trunk/test/cfi/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/lit.cfg?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/lit.cfg (original)
+++ compiler-rt/trunk/test/cfi/lit.cfg Fri Apr 21 13:11:23 2017
@@ -1,7 +1,7 @@
 import lit.formats
 import os
 
-config.name = 'cfi'
+config.name = 'cfi' + config.name_suffix
 config.suffixes = ['.c', '.cpp', '.test']
 config.test_source_root = os.path.dirname(__file__)
 
@@ -10,7 +10,7 @@ clangxx = ' '.join([config.clang] + conf
 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 '])
+  clang_cfi = ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-fsanitize=cfi '])
 
   if config.cfi_lit_test_mode == "Devirt":
     config.available_features.add('devirt')

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=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/cfi/lit.site.cfg.in Fri Apr 21 13:11:23 2017
@@ -1,6 +1,9 @@
 @LIT_SITE_CFG_IN_HEADER@
 
+config.name_suffix = "@CFI_TEST_CONFIG_SUFFIX@"
 config.cfi_lit_test_mode = "@CFI_LIT_TEST_MODE@"
+config.use_lld = @CFI_TEST_USE_LLD@
+config.use_thinlto = @CFI_TEST_USE_THINLTO@
 
 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/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lit.common.cfg Fri Apr 21 13:11:23 2017
@@ -129,6 +129,9 @@ if sanitizer_can_use_cxxabi:
   config.available_features.add('cxxabi')
 
 if config.has_lld:
+  config.available_features.add('lld-available')
+
+if config.use_lld:
   config.available_features.add('lld')
 
 if config.can_symbolize:
@@ -180,6 +183,9 @@ def is_darwin_lto_supported():
   return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib'))
 
 def is_linux_lto_supported():
+  if config.use_lld:
+    return True
+
   if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
     return False
 
@@ -202,7 +208,10 @@ if config.host_os == 'Darwin' and is_dar
 elif config.host_os == 'Linux' and is_linux_lto_supported():
   config.lto_supported = True
   config.lto_launch = []
-  config.lto_flags = ["-fuse-ld=gold"]
+  if config.use_lld:
+    config.lto_flags = ["-fuse-ld=lld"]
+  else:
+    config.lto_flags = ["-fuse-ld=gold"]
 elif config.host_os == 'Windows' and is_windows_lto_supported():
   config.lto_supported = True
   config.lto_launch = []
@@ -213,6 +222,11 @@ else:
 
 if config.lto_supported:
   config.available_features.add('lto')
+  if config.use_thinlto:
+    config.available_features.add('thinlto')
+    config.lto_flags += ["-flto=thin"]
+  else:
+    config.lto_flags += ["-flto"]
 
 # Ask llvm-config about assertion mode.
 try:

Modified: compiler-rt/trunk/test/lit.common.configured.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.configured.in?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.configured.in (original)
+++ compiler-rt/trunk/test/lit.common.configured.in Fri Apr 21 13:11:23 2017
@@ -28,6 +28,8 @@ set_default("emulator", "@COMPILER_RT_EM
 set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@)
 set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@)
 set_default("can_symbolize", @CAN_SYMBOLIZE@)
+set_default("use_lld", False)
+set_default("use_thinlto", False)
 config.available_features.add('target-is-%s' % config.target_arch)
 
 # LLVM tools dir can be passed in lit parameters, so try to

Modified: compiler-rt/trunk/test/safestack/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/safestack/lit.cfg?rev=301016&r1=301015&r2=301016&view=diff
==============================================================================
--- compiler-rt/trunk/test/safestack/lit.cfg (original)
+++ compiler-rt/trunk/test/safestack/lit.cfg Fri Apr 21 13:11:23 2017
@@ -16,7 +16,7 @@ config.substitutions.append( ("%clang_no
 config.substitutions.append( ("%clang_safestack ", config.clang + " -O0 -fsanitize=safe-stack ") )
 
 if config.lto_supported:
-  config.substitutions.append((r"%clang_lto_safestack ", ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-flto -fsanitize=safe-stack '])))
+  config.substitutions.append((r"%clang_lto_safestack ", ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-fsanitize=safe-stack '])))
 
 # SafeStack tests are currently supported on Linux, FreeBSD and Darwin only.
 if config.host_os not in ['Linux', 'FreeBSD', 'Darwin']:




More information about the llvm-commits mailing list