Skip to content

Crash with full LTO when linking Nouveau driver after LLVM commit bbdcba9b851ab #2126

@nathanchance

Description

@nathanchance

After llvm/llvm-project@bbdcba9, CI sees a crash when building ARCH={arm64,riscv} defconfig + CONFIG_LTO_CLANG_FULL=y:

https://github.com/ClangBuiltLinux/continuous-integration2/actions/runs/18308019072/job/52133404579
https://storage.tuxsuite.com/public/clangbuiltlinux/nathan/builds/33jSHeSURyDzaanz5tCXc3IEBzW/build.log

# bad: [7546bd38041612e8b768f4b315e491cd549d608c] [lldb] Add support for unique target ids (#160736)
# good: [572b579632fb79ea6eb562a537c9ff1280b3d4f5] Revert "[InstCombine] Preserve profile after folding select instructions with conditionals" (#161885)
git bisect start '7546bd38041612e8b768f4b315e491cd549d608c' '572b579632fb79ea6eb562a537c9ff1280b3d4f5'
# bad: [44b2673544bf32ae498cfa22193090f9fd7dae24] [CIR] Implement initial LoweringPrepare support for global ctors (#161452)
git bisect bad 44b2673544bf32ae498cfa22193090f9fd7dae24
# good: [795a115d1919966df72079eb3bd82699bfb2fa58] [RegAlloc] Remove default restriction on non-trivial rematerialization (#159211)
git bisect good 795a115d1919966df72079eb3bd82699bfb2fa58
# bad: [38896d67e458cf4d3b5ce0c3742f48e97527c797] [Headers][X86] Add constexpr support for some AVX512 masked extension/truncation intrinsics. (#161984)
git bisect bad 38896d67e458cf4d3b5ce0c3742f48e97527c797
# good: [718ef3427a2ddd09122e2185962e4b241848d8b9] [llvm-c-test] Fix warnings
git bisect good 718ef3427a2ddd09122e2185962e4b241848d8b9
# good: [6b1604ac30082cd7316f06c2b904cb23af95468e] [libc] add IPPROTO related macros (#161855)
git bisect good 6b1604ac30082cd7316f06c2b904cb23af95468e
# bad: [5e92e7f4c0fb9ab92572fb974591d52266be8fc6] [SCCP] Strengthen two-instruction range checks (#162008)
git bisect bad 5e92e7f4c0fb9ab92572fb974591d52266be8fc6
# bad: [bea0225c304e3f8efbca48f8c5ee4b39d8f42e0d] [AMDGPU] Make cluster a target feature (#162040)
git bisect bad bea0225c304e3f8efbca48f8c5ee4b39d8f42e0d
# bad: [bbdcba9b851abe37cf2b10ec6d9b50c12cdd3604]  [SimplifyCFG] Fold the contiguous wrapping cases into ICmp.  (#161000)
git bisect bad bbdcba9b851abe37cf2b10ec6d9b50c12cdd3604
# good: [36cfdebe927c34508c1e245b459da43b745ae620] [orc-rt] Add method-wrapper utils for use with WrapperFunction::handle. (#162035)
git bisect good 36cfdebe927c34508c1e245b459da43b745ae620
# first bad commit: [bbdcba9b851abe37cf2b10ec6d9b50c12cdd3604]  [SimplifyCFG] Fold the contiguous wrapping cases into ICmp.  (#161000)

A simplifier reproducer on top of allnoconfig:

$ cat allno.config
CONFIG_DRM=y
CONFIG_DRM_NOUVEAU=y
CONFIG_LTO_CLANG_FULL=y
CONFIG_LTO_NONE=n
CONFIG_PCI=y

$ make -skj"$(nproc)" ARCH=arm64 KCONFIG_ALLCONFIG=1 LLVM=1 clean allnoconfig vmlinux
PHINode should have one entry for each predecessor of its parent basic block!
  %100 = phi i32 [ %97, %94 ], [ -38, PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: ld.lld -EL -maarch64elf -z norelro -mllvm -import-instr-limit=5 -z noexecstack -r -o vmlinux.o -T .tmp_initcalls.lds --whole-archive vmlinux.a --no-whole-archive --start-group --end-group
1.      Running pass "verify" on module "ld-temp.o"
 #0 0x0000000001e68d2c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (ld.lld+0x1e68d2c)
 #1 0x0000000001e66670 llvm::sys::RunSignalHandlers() (ld.lld+0x1e66670)
 #2 0x0000000001e69b54 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x0000ffffb67268c0 (linux-vdso.so.1+0x8c0)
 #4 0x00000000049f9ed0 llvm::SlotTracker::SlotTracker(llvm::Function const*, bool) (ld.lld+0x49f9ed0)
 #5 0x0000000004a11cb0 createSlotTracker(llvm::Value const*) AsmWriter.cpp:0:0
 #6 0x0000000004a0f768 writeAsOperandInternal(llvm::raw_ostream&, llvm::Value const*, (anonymous namespace)::AsmWriterContext&, bool) AsmWriter.cpp:0:0
 #7 0x0000000004a06448 (anonymous namespace)::AssemblyWriter::printInstruction(llvm::Instruction const&) AsmWriter.cpp:0:0
 #8 0x0000000004a04930 llvm::Value::print(llvm::raw_ostream&, llvm::ModuleSlotTracker&, bool) const (ld.lld+0x4a04930)
 #9 0x0000000004c1f440 void llvm::VerifierSupport::CheckFailed<llvm::PHINode const*>(llvm::Twine const&, llvm::PHINode const* const&) Verifier.cpp:0:0
#10 0x0000000004bff5dc (anonymous namespace)::Verifier::verify(llvm::Function const&) Verifier.cpp:0:0
#11 0x0000000004c0716c llvm::VerifierAnalysis::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (ld.lld+0x4c0716c)
#12 0x0000000002a34800 llvm::detail::AnalysisPassModel<llvm::Module, llvm::VerifierAnalysis, llvm::AnalysisManager<llvm::Module>::Invalidator>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilder.cpp:0:0
#13 0x0000000004bd3138 llvm::AnalysisManager<llvm::Module>::getResultImpl(llvm::AnalysisKey*, llvm::Module&) (ld.lld+0x4bd3138)
#14 0x0000000004c072a4 llvm::VerifierPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (ld.lld+0x4c072a4)
#15 0x0000000004bd0c1c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (ld.lld+0x4bd0c1c)
#16 0x00000000029bb2d4 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<unsigned char>> const&) (ld.lld+0x29bb2d4)
#17 0x00000000029bbb8c llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (ld.lld+0x29bbb8c)
#18 0x00000000029a3c34 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (ld.lld+0x29a3c34)
#19 0x00000000029a3084 llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::FileCache) (ld.lld+0x29a3084)
#20 0x0000000002074768 lld::elf::BitcodeCompiler::compile() (ld.lld+0x2074768)
#21 0x0000000001fb78d4 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, true>>(bool) (ld.lld+0x1fb78d4)
#22 0x0000000001f99c18 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, true>>(llvm::opt::InputArgList&) (ld.lld+0x1f99c18)
#23 0x0000000001f82c2c lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (ld.lld+0x1f82c2c)
#24 0x0000000001f7f864 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (ld.lld+0x1f7f864)
#25 0x0000000001e6d600 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (ld.lld+0x1e6d600)
#26 0x0000000001db8554 lld_main(int, char**, llvm::ToolContext const&) (ld.lld+0x1db8554)
#27 0x0000000001db8b78 main (ld.lld+0x1db8b78)
#28 0x0000ffffb607655c __libc_start_call_main (/lib64/libc.so.6+0x2655c)
#29 0x0000ffffb607663c __libc_start_main@GLIBC_2.17 (/lib64/libc.so.6+0x2663c)
#30 0x0000000001db8130 _start (ld.lld+0x1db8130)
make[4]: *** [scripts/Makefile.vmlinux_o:72: vmlinux.o] Error 139
...

I managed to find two files that trigger this issue so I am going to try and reduce that out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compiler crashThis bug makes Clang crash, emitting a backtraceReported upstreamThis bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.[BUG] llvm (main)A bug in an unreleased version of LLVM (this label is appropriate for regressions)[FEATURE] LTORelated to building the kernel with LLVM Link Time Optimization[FIXED][LLVM] mainThis bug was only present and fixed in an unreleased version of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions