[PATCH] D150505: [cmake] Disable GCC lifetime DSE
Xi Ruoyao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 22:29:33 PDT 2023
xry111 created this revision.
xry111 added reviewers: MaskRay, thesamesam.
Herald added a subscriber: ekilmer.
Herald added a project: All.
xry111 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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). Before
refactoring these data structures, we need to disable dead store
eliminations based on object lifetime so the issue won't explode.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150505
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -594,6 +594,16 @@
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). Before
+ # refactoring these data structures, we need to disable dead store
+ # eliminations based on object lifetime so the issue won't explode.
+ 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})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150505.521869.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230513/6dc1119c/attachment.bin>
More information about the llvm-commits
mailing list