summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2023-05-14 03:42:45 +0100
committerTom Stellard <tstellar@redhat.com>2023-05-16 19:51:03 -0700
commitd5cce0a7781bfbb9322a2e9625c7f88253801148 (patch)
tree2f6022880271e85be93d2f193675588801c99560
parent57262bbd32c35eb05bac34e39a751abc0466b9da (diff)
downloadllvm-d5cce0a7781bfbb9322a2e9625c7f88253801148.tar.gz
[cmake] Disable GCC lifetime DSE
LLVM data structures like llvm::User and llvm::MDNode rely on the value of object storage persisting beyond the lifetime of the object (#24952). This is not standard compliant and causes a runtime crash if LLVM is built with GCC and LTO enabled (#57740). Until these issues are fixed, we need to disable dead store eliminations eliminations based on object lifetime. The previous test issues are fixed by 626849c71e85d546a004cc91866beab610222194. Bug: https://github.com/llvm/llvm-project/issues/24952 Bug: https://github.com/llvm/llvm-project/issues/57740 Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106943 Reviewed By: MaskRay, thesamesam, nikic Differential Revision: https://reviews.llvm.org/D150505 (cherry picked from commit 47f5c54f997a59bb2c65abe6b8b811f6e7553456)
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 6119ecdce0f4..78be03d2bc13 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -582,6 +582,16 @@ if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
+if ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
+ # LLVM data structures like llvm::User and llvm::MDNode rely on
+ # the value of object storage persisting beyond the lifetime of the
+ # object (#24952). This is not standard compliant and causes a runtime
+ # crash if LLVM is built with GCC and LTO enabled (#57740). Until
+ # these bugs are fixed, we need to disable dead store eliminations
+ # based on object lifetime.
+ add_flag_if_supported("-fno-lifetime-dse" CMAKE_CXX_FLAGS)
+endif ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
+
# Modules enablement for GCC-compatible compilers:
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE AND LLVM_ENABLE_MODULES )
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})