[llvm-bugs] [Bug 51882] New: "fragment is larger than or outside of variable" and "fragment covers entire variable" with LTO

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 16 15:06:08 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51882

            Bug ID: 51882
           Summary: "fragment is larger than or outside of variable" and
                    "fragment covers entire variable" with LTO
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: efriedma at quicinc.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Testcase follows. The given code is an ODR violation, but it shouldn't crash.

a.cpp:
struct X {
  long a;
  bool b;
};
void f() { X z; z.b=true; }

b.cpp:
struct X {
  long a;
};
X y;

$ clang -shared -flto b.cpp a.cpp -fuse-ld=lld -g -O

fragment covers entire variable
  call void @llvm.dbg.declare(metadata i64* undef, metadata !23, metadata
!DIExpression(DW_OP_LLVM_fragment, 0, 64)), !dbg !24
!23 = !DILocalVariable(name: "z", scope: !19, file: !10, line: 5, type: !5)
fragment is larger than or outside of variable
  call void @llvm.dbg.declare(metadata [7 x i8]* undef, metadata !23, metadata
!DIExpression(DW_OP_LLVM_fragment, 72, 56)), !dbg !24
!23 = !DILocalVariable(name: "z", scope: !19, file: !10, line: 5, type: !5)
fragment is larger than or outside of variable
  call void @llvm.dbg.value(metadata i8 1, metadata !23, metadata
!DIExpression(DW_OP_LLVM_fragment, 64, 8)), !dbg !25
!23 = !DILocalVariable(name: "z", scope: !19, file: !10, line: 5, type: !5)
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments:
/usr2/efriedma/local/upstream-build-release/bin/ld.lld -z relro
--hash-style=gnu --eh-frame-hdr -m elf_x86_64 -shared -o a.out
/usr/lib/x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/crtbeginS.o
-L/usr/lib/gcc/x86_64-linux-gnu/5.4.0 -L/lib/x86_64-linux-gnu -L/lib/../lib64
-L/usr/lib/x86_64-linux-gnu
-L/local/mnt2/workspace2/efriedma/upstream-build-release/bin/../lib -L/lib
-L/usr/lib -plugin-opt=mcpu=x86-64 -plugin-opt=O1 /tmp/b-359201.o
/tmp/a-fa0ce5.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed
-lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/5.4.0/crtendS.o
/usr/lib/x86_64-linux-gnu/crtn.o
 #0 0x0000000003185493 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x3185493)
 #1 0x000000000318305e llvm::sys::RunSignalHandlers()
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x318305e)
 #2 0x0000000003185a86 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f8d80370390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #4 0x00007f8d7ed5a438 raise
/build/glibc-e6zv40/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
 #5 0x00007f8d7ed5c03a abort /build/glibc-e6zv40/glibc-2.23/stdlib/abort.c:91:0
 #6 0x00000000030ebaa8
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x30ebaa8)
 #7 0x00000000030eb8f8
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x30eb8f8)
 #8 0x00000000066b9896
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x66b9896)
 #9 0x000000000492e4cd llvm::detail::PassModel<llvm::Module,
llvm::VerifierPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&) LTOBackend.cpp:0:0
#10 0x000000000668c0ef llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x668c0ef)
#11 0x0000000004927ded llvm::lto::opt(llvm::lto::Config const&,
llvm::TargetMachine*, unsigned int, llvm::Module&, bool,
llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*,
std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x4927ded)
#12 0x000000000492941a llvm::lto::backend(llvm::lto::Config const&,
std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream,
std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>,
unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x492941a)
#13 0x0000000004919783
llvm::lto::LTO::runRegularLTO(std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream,
std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x4919783)
#14 0x0000000004918b45
llvm::lto::LTO::run(std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream,
std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>,
std::__1::function<std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream,
std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>
(unsigned int, llvm::StringRef)>)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x4918b45)
#15 0x000000000331c4f4 lld::elf::BitcodeCompiler::compile()
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x331c4f4)
#16 0x000000000327e136 void
lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1,
true> >() (/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x327e136)
#17 0x0000000003269617 void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
true> >(llvm::opt::InputArgList&)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x3269617)
#18 0x00000000032582fc lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char
const*>) (/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x32582fc)
#19 0x0000000003256352 lld::elf::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&, llvm::raw_ostream&)
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x3256352)
#20 0x00000000030cbb06 lldMain(int, char const**, llvm::raw_ostream&,
llvm::raw_ostream&, bool) lld.cpp:0:0
#21 0x00000000030cb345 main
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x30cb345)
#22 0x00007f8d7ed45840 __libc_start_main
/build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:325:0
#23 0x00000000030cb029 _start
(/usr2/efriedma/local/upstream-build-release/bin/ld.lld+0x30cb029)
clang-13: error: unable to execute command: Aborted
clang-13: error: linker command failed due to signal (use -v to see invocation)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210916/641e5bfa/attachment.html>


More information about the llvm-bugs mailing list