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 version (D150505) also exploited an issue in the
clang-tidy test suite. The test trivially-destructible.cpp is filtered
into a temporary file, and when clang-tidy operates on the file, the
compile_commands.json file in the build directory will be read and
the compiler options in it will be used. If LLVM is not built with Clang,
some of the options may be unsupported, causing a test failure. Fix
it by adding "-p %s" into the test command to force clang-tidy to
search the compiler option DB file in the source directory, where there
is none.
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