Skip to content

Commit d5cce0a

Browse files
xry111tstellar
authored andcommitted
[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 (llvm#24952). This is not standard compliant and causes a runtime crash if LLVM is built with GCC and LTO enabled (llvm#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 626849c. Bug: llvm#24952 Bug: llvm#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 47f5c54)
1 parent 57262bb commit d5cce0a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,16 @@ if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
582582
add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
583583
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
584584

585+
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
586+
# LLVM data structures like llvm::User and llvm::MDNode rely on
587+
# the value of object storage persisting beyond the lifetime of the
588+
# object (#24952). This is not standard compliant and causes a runtime
589+
# crash if LLVM is built with GCC and LTO enabled (#57740). Until
590+
# these bugs are fixed, we need to disable dead store eliminations
591+
# based on object lifetime.
592+
add_flag_if_supported("-fno-lifetime-dse" CMAKE_CXX_FLAGS)
593+
endif ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
594+
585595
# Modules enablement for GCC-compatible compilers:
586596
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE AND LLVM_ENABLE_MODULES )
587597
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})

0 commit comments

Comments
 (0)