[CMake] Add -O1 in debug builds with LLVM_USE_SANITIZER
authorAlexey Samsonov <samsonov@google.com>
Mon, 2 Sep 2013 09:15:01 +0000 (09:15 +0000)
committerAlexey Samsonov <samsonov@google.com>
Mon, 2 Sep 2013 09:15:01 +0000 (09:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189747 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/HandleLLVMOptions.cmake

index b49d6496125030778e47712fc4075cbc0bfbdcbc..4d56438f18de9fb4e89662c64095a93d3beca64c 100644 (file)
@@ -240,6 +240,10 @@ macro(append_common_sanitizer_flags)
       NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
     add_flag_if_supported("-gline-tables-only")
   endif()
+  # Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
+  if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+    add_flag_if_supported("-O1")
+  endif()
 endmacro()
 
 # Turn on sanitizers if necessary.