[compiler-rt] 7142eb1 - sanitizers: compile with -O1 under debug

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 01:01:54 PDT 2021


Author: Dmitry Vyukov
Date: 2021-08-16T10:01:50+02:00
New Revision: 7142eb17fb3419a76c9ac4afce0df986ff08d61c

URL: https://github.com/llvm/llvm-project/commit/7142eb17fb3419a76c9ac4afce0df986ff08d61c
DIFF: https://github.com/llvm/llvm-project/commit/7142eb17fb3419a76c9ac4afce0df986ff08d61c.diff

LOG: sanitizers: compile with -O1 under debug

Tsan's check_memcpy.c test was disabled under debug because it failed.
But it points to real issues and does not help to just disable it.
I tried to enable it and see what fail and the first hit was default ctor for:

  struct ChainedOriginDepotDesc {
    u32 here_id;
    u32 prev_id;
  };

initializing these fields to 0's help partially,
but compiler still emits memset before calling ctor.
I did not try to see what's the next failure, because if it fails
on such small structs, it won't be realistic to fix everything
and keep working.

Compile runtimes with -O1 under debug instead.
It seems to fix all current failures. At least I run check-tsan
under clang/gcc x debug/non-debug and all combinations passed.
-O1 does not usually use too aggressive optimizations
and sometimes even makes debugging easier because machine code
is not exceedingly verbose.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D107962

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt
    compiler-rt/test/tsan/Linux/check_memcpy.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 83a68a4b04468..fc8a0cf6d46c5 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -378,7 +378,7 @@ if (NOT MSVC)
 
   # Build with optimization, unless we're in debug mode.
   if(COMPILER_RT_DEBUG)
-    list(APPEND SANITIZER_COMMON_CFLAGS -O0)
+    list(APPEND SANITIZER_COMMON_CFLAGS -O1)
   else()
     list(APPEND SANITIZER_COMMON_CFLAGS -O3)
   endif()

diff  --git a/compiler-rt/test/tsan/Linux/check_memcpy.c b/compiler-rt/test/tsan/Linux/check_memcpy.c
index 75dd7da8316ba..55705ce8154c2 100644
--- a/compiler-rt/test/tsan/Linux/check_memcpy.c
+++ b/compiler-rt/test/tsan/Linux/check_memcpy.c
@@ -3,9 +3,7 @@
 // its objdump.
 
 // RUN: %clang_tsan -O1 %s -o %t
-// RUN: llvm-objdump -d %t | FileCheck %s
-
-// REQUIRES: compiler-rt-optimized
+// RUN: llvm-objdump -d -l %t | FileCheck %s
 
 int main() {
   return 0;


        


More information about the llvm-commits mailing list