Trying to compile Python 3.9.2 with clang 12 (release branch as of 2021/02/23) with LTO enabled results in:
ld: /home/bero/abf/llvm/BUILD/llvm-project-release-12.x/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp:87: void llvm::InstructionPrecedenceTracking::validate(const llvm::BasicBlock *) const: Assertion `It->second == &Insn && "Cached first special instruction is wrong!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
Extended Description
Trying to compile Python 3.9.2 with clang 12 (release branch as of 2021/02/23) with LTO enabled results in:
ld: /home/bero/abf/llvm/BUILD/llvm-project-release-12.x/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp:87: void llvm::InstructionPrecedenceTracking::validate(const llvm::BasicBlock *) const: Assertion `It->second == &Insn && "Cached first special instruction is wrong!"' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump:
0 0x00007f20a0d0cce1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib64/libLLVMSupport.so.12.0+0x235ce1)
1 0x00007f20a0d0cfbd (/usr/lib64/libLLVMSupport.so.12.0+0x235fbd)
2 0x00007f20a0d0a90a llvm::sys::RunSignalHandlers() (/usr/lib64/libLLVMSupport.so.12.0+0x23390a)
3 0x00007f20a0d0d2d6 (/usr/lib64/libLLVMSupport.so.12.0+0x2362d6)
4 0x00007f20a07439c0 __restore_rt (/lib64/libc.so.6+0x409c0)
5 0x00007f20a074393f raise (/lib64/libc.so.6+0x4093f)
6 0x00007f20a0729538 abort (/lib64/libc.so.6+0x26538)
7 0x00007f20a0729421 _nl_load_domain.cold (/lib64/libc.so.6+0x26421)
8 0x00007f20a073ac82 (/lib64/libc.so.6+0x37c82)
9 0x00007f209a17db26 llvm::InstructionPrecedenceTracking::validate(llvm::BasicBlock const*) const (/usr/lib64/libLLVMAnalysis.so.12.0+0x3d3b26)
10 0x00007f209a17d5ec llvm::InstructionPrecedenceTracking::getFirstSpecialInstruction(llvm::BasicBlock const*) (/usr/lib64/libLLVMAnalysis.so.12.0+0x3d35ec)
11 0x00007f209a17de5f llvm::InstructionPrecedenceTracking::isPreceededBySpecialInstruction(llvm::Instruction const*) (/usr/lib64/libLLVMAnalysis.so.12.0+0x3d3e5f)
12 0x00007f209a602530 llvm::GVN::PerformLoadPRE(llvm::LoadInst, llvm::SmallVector<llvm::gvn::AvailableValueInBlock, 64u>&, llvm::SmallVector<llvm::BasicBlock, 64u>&) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x229530)
13 0x00007f209a60596c llvm::GVN::processNonLocalLoad(llvm::LoadInst*) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x22c96c)
14 0x00007f209a608125 llvm::GVN::processLoad(llvm::LoadInst*) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x22f125)
15 0x00007f209a609cf4 llvm::GVN::processInstruction(llvm::Instruction*) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x230cf4)
16 0x00007f209a60b6d9 llvm::GVN::processBlock(llvm::BasicBlock*) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x2326d9)
17 0x00007f209a60a9bc llvm::GVN::iterateOnFunction(llvm::Function&) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x2319bc)
18 0x00007f209a60089b llvm::GVN::runImpl(llvm::Function&, llvm::AssumptionCache&, llvm::DominatorTree&, llvm::TargetLibraryInfo const&, llvm::AAResults&, llvm::MemoryDependenceResults, llvm::LoopInfo, llvm::OptimizationRemarkEmitter, llvm::MemorySSA) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x22789b)
19 0x00007f209a5ffea8 llvm::GVN::run(llvm::Function&, llvm::AnalysisManager&) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x226ea8)
20 0x00007f209c5aea8f (/usr/lib64/libLLVMPasses.so.12.0+0x17aa8f)
21 0x00007f209b586946 llvm::PassManager<llvm::Function, llvm::AnalysisManager >::run(llvm::Function&, llvm::AnalysisManager&) (/usr/lib64/libLLVMCore.so.12.0+0x42c946)
22 0x00007f209fea0c1f (/usr/lib64/libLLVMAMDGPUCodeGen.so.12.0+0x56ec1f)
23 0x00007f209b58bfa9 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/usr/lib64/libLLVMCore.so.12.0+0x431fa9)
24 0x00007f209fea097f (/usr/lib64/libLLVMAMDGPUCodeGen.so.12.0+0x56e97f)
25 0x00007f209b584fc9 llvm::PassManager<llvm::Module, llvm::AnalysisManager >::run(llvm::Module&, llvm::AnalysisManager&) (/usr/lib64/libLLVMCore.so.12.0+0x42afc9)
26 0x00007f209d2a701c llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator > const&) (/usr/lib64/libLLVMLTO.so.12.0+0x5701c)
27 0x00007f209d2a7fc1 llvm::lto::backend(llvm::lto::Config const&, std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete > (unsigned int)>, unsigned int, std::unique_ptr<llvm::Module, std::default_delete >, llvm::ModuleSummaryIndex&) (/usr/lib64/libLLVMLTO.so.12.0+0x57fc1)
28 0x00007f209d2974f9 llvm::lto::LTO::runRegularLTO(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete > (unsigned int)>) (/usr/lib64/libLLVMLTO.so.12.0+0x474f9)
29 0x00007f209d296a6f llvm::lto::LTO::run(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete > (unsigned int)>, std::function<std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete > (unsigned int)> (unsigned int, llvm::StringRef)>) (/usr/lib64/libLLVMLTO.so.12.0+0x46a6f)
30 0x00007f20a120a2cc lld::elf::BitcodeCompiler::compile() (/usr/lib64/liblldELF.so.12.0+0x2032cc)
31 0x00007f20a1181696 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1, true> >() (/usr/lib64/liblldELF.so.12.0+0x17a696)
32 0x00007f20a116d491 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) (/usr/lib64/liblldELF.so.12.0+0x166491)
33 0x00007f20a115e482 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/lib64/liblldELF.so.12.0+0x157482)
34 0x00007f20a115bd2b lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) (/usr/lib64/liblldELF.so.12.0+0x154d2b)
35 0x00000000002051bc (/usr/bin/ld+0x2051bc)
36 0x0000000000204a02 main (/usr/bin/ld+0x204a02)
37 0x00007f20a072b56d __libc_start_main (/lib64/libc.so.6+0x2856d)
38 0x000000000020451a _start (/usr/bin/ld+0x20451a)
clang-12: error: unable to execute command: Aborted (core dumped) clang-12: error: linker command failed due to signal (use -v to see invocation)
Without LTO, it compiles and works fine.