[llvm] 5ccf546 - [llvm][cmake] Performing expensive checks requires enabling assert. (#80821)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 18:25:07 PST 2024


Author: huaatian
Date: 2024-02-23T10:25:02+08:00
New Revision: 5ccf54640a2bdb6f36f65c574feb312da7f75243

URL: https://github.com/llvm/llvm-project/commit/5ccf54640a2bdb6f36f65c574feb312da7f75243
DIFF: https://github.com/llvm/llvm-project/commit/5ccf54640a2bdb6f36f65c574feb312da7f75243.diff

LOG: [llvm][cmake] Performing expensive checks requires enabling assert. (#80821)

LLVM will intercept errors using assert() when
LLVM_ENABLE_EXPENSIVE_CHECKS is ON. So an explicit check is added.

---------

Co-authored-by: Hua Tian <akiratian at tencent.com>

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 4257083e53ad48..40316b11ceed9b 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -128,6 +128,11 @@ if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn" OR
 endif()
 
 if(LLVM_ENABLE_EXPENSIVE_CHECKS)
+  # When LLVM_ENABLE_EXPENSIVE_CHECKS is ON, LLVM will intercept errors
+  # using assert(). An explicit check is performed here.
+  if (NOT LLVM_ENABLE_ASSERTIONS)
+    message(FATAL_ERROR "LLVM_ENABLE_EXPENSIVE_CHECKS requires LLVM_ENABLE_ASSERTIONS \"ON\".")
+  endif()
   add_compile_definitions(EXPENSIVE_CHECKS)
 
   # In some libstdc++ versions, std::min_element is not constexpr when


        


More information about the llvm-commits mailing list