[lld] ELF: Add branch-to-branch optimization. (PR #138366)
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 24 12:54:36 PDT 2025
pcc wrote:
> We're hitting an assert after this. I've attached a reproducer at https://crbug.com/427013249#comment3
>
> ```
> $ tar zxf /tmp/repro.tar.gz
> $ ( cd repro && ../build/bin/ld.lld @response.txt )
> ld.lld: /work/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = lld::elf::InputSection; From = lld::elf::InputSectionBase]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
> PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
> Stack dump:
> 0. Program arguments: ../build/bin/ld.lld @response.txt
> #0 0x000055ef8070ae7b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../build/bin/ld.lld+0x132ae7b)
> #1 0x000055ef80707f76 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
> #2 0x00007f356d359df0 (/lib/x86_64-linux-gnu/libc.so.6+0x3fdf0)
> #3 0x00007f356d3ae95c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
> #4 0x00007f356d359cc2 raise ./signal/../sysdeps/posix/raise.c:27:6
> #5 0x00007f356d3424ac abort ./stdlib/abort.c:81:3
> #6 0x00007f356d342420 __assert_perror_fail ./assert/assert-perr.c:31:1
> #7 0x000055ef80042c1d (anonymous namespace)::X86_64::applyBranchToBranchOpt() const (.cold) X86_64.cpp:0:0
> #8 0x000055ef80a287e4 (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, true>>::finalizeSections() Writer.cpp:0:0
> #9 0x000055ef80a2a3f0 void lld::elf::writeResult<llvm::object::ELFType<(llvm::endianness)1, true>>(lld::elf::Ctx&) (../build/bin/ld.lld+0x164a3f0)
> #10 0x000055ef80884a35 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, true>>(llvm::opt::InputArgList&) (../build/bin/ld.lld+0x14a4a35)
> #11 0x000055ef8088bfe2 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (../build/bin/ld.lld+0x14abfe2)
> #12 0x000055ef8088c8ff lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (../build/bin/ld.lld+0x14ac8ff)
> #13 0x000055ef8074349a lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (../build/bin/ld.lld+0x136349a)
> #14 0x000055ef80681409 lld_main(int, char**, llvm::ToolContext const&) (../build/bin/ld.lld+0x12a1409)
> #15 0x000055ef80532643 main (../build/bin/ld.lld+0x1152643)
> #16 0x00007f356d343ca8 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
> #17 0x00007f356d343d65 call_init ./csu/../csu/libc-start.c:128:20
> #18 0x00007f356d343d65 __libc_start_main ./csu/../csu/libc-start.c:347:5
> #19 0x000055ef80680ce1 _start (../build/bin/ld.lld+0x12a0ce1)
> Aborted (core dumped)
> ```
>
> I'll revert this for now.
Thanks, sent #145579 with the fix.
https://github.com/llvm/llvm-project/pull/138366
More information about the llvm-commits
mailing list