llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.04k stars 11.98k forks source link

Regression (12.0) Assertion `It->second == &Insn && "Cached first special instruction is wrong!"' failed. #48671

Closed berolinux closed 1 year ago

berolinux commented 3 years ago
Bugzilla Link 49327
Version trunk
OS Linux
Attachments test case

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:

  1. Program arguments: /usr/bin/ld --build-id --eh-frame-hdr -m elf_x86_64 -shared -o libpython3.9.so.1.0 /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/10.2.1/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/10.2.1/crtbeginS.o -L/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/10.2.1 -L/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/10.2.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib -L/lib -L/usr/lib -plugin /usr/bin/../lib64/LLVMgold.so -plugin-opt=mcpu=znver1 -plugin-opt=O3 -O2 -O2 -hlibpython3.9.so.1.0 Modules/getbuildinfo.o Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/token.o Parser/pegen/pegen.o Parser/pegen/parse.o Parser/pegen/parse_string.o Parser/pegen/peg_api.o Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o Objects/abstract.o Objects/accu.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/interpreteridobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/weakrefobject.o Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/ceval.o Python/codecs.o Python/compile.o Python/context.o Python/dynamic_annotations.o Python/errors.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/graminit.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/initconfig.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/pathconfig.o Python/peephole.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/bootstrap_hash.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/dynload_shlib.o Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/_abc.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/signalmodule.o Modules/_stat.o Modules/timemodule.o Modules/_threadmodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/_peg_parser.o Modules/symtablemodule.o Modules/xxsubtype.o Python/frozen.o -lcrypt -lintl -lpthread -ldl -lutil -lm -lm -u__llvm_profile_runtime /usr/lib64/clang/12.0.0/lib/linux/libclang_rt.profile-x86_64.a -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/10.2.1/crtendS.o /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/10.2.1/../../../../lib64/crtn.o

    ​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.

xgupta commented 1 year ago

Duplicate of https://github.com/llvm/llvm-project/issues/48805.