llvm / llvm/llvm-project

[LTO] [23.1-rc3] fragment covers entire variable/fragment is larger than or outside of variable

Open
#216,495 2 comments 0 reactions 0 assignees View on GitHub
crash LTO
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

[small.cpp](https://github.com/user-attachments/files/31103294/small.cpp)

[large.cpp](https://github.com/user-attachments/files/31103297/large.cpp)

[main.cpp](https://github.com/user-attachments/files/31103298/main.cpp)

Building the attached files with _O3, LTO and debug info fails:

```
[bero@ryzen9 lto-repro]$ clang++ -O3 -flto -g -c small.cpp
[bero@ryzen9 lto-repro]$ clang++ -O3 -flto -g -c large.cpp
[bero@ryzen9 lto-repro]$ clang++ -O3 -flto -g -c main.cpp
[bero@ryzen9 lto-repro]$ clang++ -O3 -g -flto -o repro small.o large.o main.o
fragment covers entire variable
#dbg_value(double %0, !66, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !77)
!66 = !DILocalVariable(name: "p1", scope: !59, file: !22, line: 26, type: !3)
fragment is larger than or outside of variable
#dbg_value(double %1, !66, !DIExpression(DW_OP_LLVM_fragment, 64, 64), !77)
!66 = !DILocalVariable(name: "p1", scope: !59, file: !22, line: 26, type: !3)
fragment is larger than or outside of variable
#dbg_value(double 0.000000e+00, !66, !DIExpression(DW_OP_LLVM_fragment, 128, 64), !77)
!66 = !DILocalVariable(name: "p1", scope: !59, file: !22, line: 26, type: !3)
fragment covers entire variable
#dbg_value(double 6.553600e+04, !67, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !77)
!67 = !DILocalVariable(name: "leftmost", scope: !59, file: !22, line: 27, type: !3)
fragment is larger than or outside of variable
#dbg_value(double 0.000000e+00, !67, !DIExpression(DW_OP_LLVM_fragment, 64, 64), !77)
!67 = !DILocalVariable(name: "leftmost", scope: !59, file: !22, line: 27, type: !3)
fragment is larger than or outside of variable
#dbg_value(double 0.000000e+00, !67, !DIExpression(DW_OP_LLVM_fragment, 128, 64), !77)
!67 = !DILocalVariable(name: "leftmost", scope: !59, file: !22, line: 27, type: !3)
fragment covers entire variable
#dbg_value(double %3, !68, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !77)
!68 = !DILocalVariable(name: "a", scope: !59, file: !22, line: 28, type: !3)
fragment covers entire variable
#dbg_value(double %3, !74, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !75)
!74 = !DILocalVariable(name: "temp", scope: !71, file: !22, line: 14, type: !3)
fragment is larger than or outside of variable
#dbg_value(double %1, !68, !DIExpression(DW_OP_LLVM_fragment, 64, 64), !77)
!68 = !DILocalVariable(name: "a", scope: !59, file: !22, line: 28, type: !3)
fragment is larger than or outside of variable
#dbg_value(double %1, !74, !DIExpression(DW_OP_LLVM_fragment, 64, 64), !75)
!74 = !DILocalVariable(name: "temp", scope: !71, file: !22, line: 14, type: !3)
fragment is larger than or outside of variable
#dbg_value(double poison, !68, !DIExpression(DW_OP_LLVM_fragment, 128, 64), !77)
!68 = !DILocalVariable(name: "a", scope: !59, file: !22, line: 28, type: !3)
fragment is larger than or outside of variable
#dbg_value(double poison, !74, !DIExpression(DW_OP_LLVM_fragment, 128, 64), !75)
!74 = !DILocalVariable(name: "temp", scope: !71, file: !22, line: 14, type: !3)
LLVM ERROR: Broken module found, compilation aborted!
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: /usr/bin/ld.lld -z relro --hash-style=gnu --build-id=sha1 --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o repro /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0/../../../../lib64/Scrt1.o /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0/crtbeginS.o -L/usr/lib64/clang/23/lib/x86_64-pc-linux-gnu -L/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0 -L/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib64 -L/lib -L/usr/lib -plugin-opt=mcpu=x86-64 -plugin-opt=O3 -L/usr/lib/asmc -L/usr/lib/asmc small.o large.o main.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0/crtendS.o /usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/16.2.0/../../../../lib64/crtn.o
1. Running pass "verify" on module "ld-temp.o"
#0 0x00007f7a3f26613c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM.so.23.1+0x4c6613c)
#1 0x00007f7a3f264453 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.23.1+0x4c64453)
#2 0x00007f7a3f2658be (/lib64/libLLVM.so.23.1+0x4c658be)
#3 0x00007f7a39e417e0 (/lib64/libc.so.6+0x417e0)
#4 0x00007f7a39e9ad3c (/lib64/libc.so.6+0x9ad3c)
#5 0x00007f7a39e416c2 raise (/lib64/libc.so.6+0x416c2)
#6 0x00007f7a39e291b2 abort (/lib64/libc.so.6+0x291b2)
#7 0x00007f7a3f167296 llvm::report_fatal_error(llvm::Twine const&, bool) (/lib64/libLLVM.so.23.1+0x4b67296)
#8 0x00007f7a3f1670b6 (/lib64/libLLVM.so.23.1+0x4b670b6)
#9 0x00007f7a41615b61 (/lib64/libLLVM.so.23.1+0x7015b61)
#10 0x00007f7a3f6898f5 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/lib64/libLLVM.so.23.1+0x50898f5)
#11 0x00007f7a41613c9c llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector> const&, llvm::ArrayRef) (/lib64/libLLVM.so.23.1+0x7013c9c)
#12 0x00007f7a41615e62 llvm::lto::backend(llvm::lto::Config const&, std::function>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&, llvm::ArrayRef) (/lib64/libLLVM.so.23.1+0x7015e62)
#13 0x00007f7a415fbda2 llvm::lto::LTO::runRegularLTO(std::function>> (unsigned int, llvm::Twine const&)>) (/lib64/libLLVM.so.23.1+0x6ffbda2)
#14 0x00007f7a415faeba llvm::lto::LTO::run(std::function>> (unsigned int, llvm::Twine const&)>, llvm::FileCache) (/lib64/libLLVM.so.23.1+0x6ffaeba)
#15 0x00005619879efdc4 lld::elf::BitcodeCompiler::compile() (/usr/bin/ld.lld+0x34fdc4)
#16 0x0000561987907f91 (/usr/bin/ld.lld+0x267f91)
#17 0x00005619878e5ae6 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef) (/usr/bin/ld.lld+0x245ae6)
#18 0x00005619878e147c lld::elf::link(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/bin/ld.lld+0x24147c)
#19 0x00005619877db18a lld::unsafeLldMain(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef, bool) (/usr/bin/ld.lld+0x13b18a)
#20 0x00005619877da531 lld_main(int, char**, llvm::ToolContext const&) (/usr/bin/ld.lld+0x13a531)
#21 0x00005619877da791 main (/usr/bin/ld.lld+0x13a791)
#22 0x00007f7a39e2aff8 (/lib64/libc.so.6+0x2aff8)
#23 0x00007f7a39e2b117 __libc_start_main (/lib64/libc.so.6+0x2b117)
#24 0x00005619877d8a11 _start (/usr/bin/ld.lld+0x138a11)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: linker command failed with exit code -2 (use -v to see invocation)
Aborted (core dumped) clang++ -O3 -g -flto -o repro small.o large.o main.o
[bero@ryzen9 lto-repro]$
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the linker failure with small.cpp, large.cpp, and main.cpp using the reported -O3 -flto -g commands. Read the emitted debug fragments and the LTO verification failure; done means the attached reproducer links without the broken-module error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.