This is an archive of the discontinued LLVM Phabricator instance.

Revert "[DWARF] Create subprogram's DIE in DISubprogram's unit"
ClosedPublic

Authored by SureYeaah on Jan 28 2021, 8:22 AM.

Details

Summary

This reverts commit ef0dcb506300dc9644e8000c6028d14214be9d97.

This change is causing a lot of compiler crashes.

Diff Detail

Event Timeline

SureYeaah created this revision.Jan 28 2021, 8:22 AM
SureYeaah requested review of this revision.Jan 28 2021, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2021, 8:22 AM

I am trying to create a small repro for this that I can share but it would be great if we could revert this asap.

rupprecht accepted this revision.Jan 28 2021, 8:25 AM
This revision is now accepted and ready to land.Jan 28 2021, 8:25 AM
This revision was landed with ongoing or failed builds.Jan 28 2021, 8:40 AM
This revision was automatically updated to reflect the committed changes.

Sure, please do revert if this is causing a crash.

I'm aware that there's a latent bug hanging around, documented in https://bugs.llvm.org/show_bug.cgi?id=37255 that could be related. (This is speculation right now).

Here's the stacktrace from a crash:

 #0 0x00005568d4c35205 SignalHandler(int) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x5d5e205)
 #1 0x00007f00dfea89a0 __restore_rt (/usr/grte/v4/lib64/libpthread.so.0+0xf9a0)
 #2 0x00005568d2756aa0 llvm::DIE::computeOffsetsAndAbbrevs(llvm::AsmPrinter const*, llvm::DIEAbbrevSet&, unsigned int) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x387faa0)
 #3 0x00005568d2757edc llvm::DIE::computeOffsetsAndAbbrevs(llvm::AsmPrinter const*, llvm::DIEAbbrevSet&, unsigned int) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3880edc)
 #4 0x00005568d2757edc llvm::DIE::computeOffsetsAndAbbrevs(llvm::AsmPrinter const*, llvm::DIEAbbrevSet&, unsigned int) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3880edc)
 #5 0x00005568d178ae88 llvm::DwarfFile::computeSizeAndOffsets() (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x28b3e88)
 #6 0x00005568d1788a28 llvm::DwarfDebug::endModule() (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x28b1a28)
 #7 0x00005568d2c9f5f9 llvm::AsmPrinter::doFinalization(llvm::Module&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3dc85f9)
 #8 0x00005568d1edae12 llvm::FPPassManager::doFinalization(llvm::Module&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3003e12)
 #9 0x00005568d1b27ac3 llvm::legacy::PassManagerImpl::run(llvm::Module&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c50ac3)
#10 0x00005568d1b26d20 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::__u::function<std::__u::unique_ptr<llvm::lto::NativeObjectStream, std::__u::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c4fd20)
#11 0x00005568d1b2514a llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::__u::function<std::__u::unique_ptr<llvm::lto::NativeObjectStream, std::__u::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long> >, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*> > const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >, std::__u::vector<std::__u::pair<llvm::StringRef, llvm::BitcodeModule>, std::__u::allocator<std::__u::pair<llvm::StringRef, llvm::BitcodeModule> > > >&, std::__u::vector<unsigned char, std::__u::allocator<unsigned char> > const&)::$_2::operator()(llvm::Module&, llvm::TargetMachine*, std::__u::unique_ptr<llvm::ToolOutputFile, std::__u::default_delete<llvm::ToolOutputFile> >) const (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c4e14a)
#12 0x00005568d1b24288 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::__u::function<std::__u::unique_ptr<llvm::lto::NativeObjectStream, std::__u::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long> >, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*> > const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >, std::__u::vector<std::__u::pair<llvm::StringRef, llvm::BitcodeModule>, std::__u::allocator<std::__u::pair<llvm::StringRef, llvm::BitcodeModule> > > >&, std::__u::vector<unsigned char, std::__u::allocator<unsigned char> > const&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c4d288)
#13 0x00005568d1b1e54d clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream> >) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2c4754d)
#14 0x00005568d189269e clang::CodeGenAction::ExecuteAction() (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x29bb69e)
#15 0x00005568d19eb395 clang::FrontendAction::Execute() (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2b14395)
#16 0x00005568d19eaa21 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2b13a21)
#17 0x00005568d19e998c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2b1298c)
#18 0x00005568d19dc944 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2b05944)
#19 0x00005568d19dbdfd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2b04dfd)
#20 0x00005568d235dcfb main (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x3486cfb)
#21 0x00007f00dfd16bbd __libc_start_main (/usr/grte/v4/lib64/libc.so.6+0x38bbd)
#22 0x00005568d1e25659 _start (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2f4e65
jmorse added a comment.Feb 2 2021, 8:35 AM

The stack trace is exploding when enumerating child DIEs, so it seems possible that this is running into another scenario where a subprogram is referred to incorrectly across CUs, and that wouldn't be surprising. To state the obvious, we'll need a reproducer to pin down where this is coming from.

I can reproduce the issue internally as well, so I can try to reduce something.

Oddly, my initial attempts to build with an release+asserts build makes the crash disappear, so I can't say if it's the same issue as http://llvm.org/PR37255 (which is an assertion failure).

While I'm reducing the source, the minimal flags to hit this seem to be clang -g -mllvm -generate-type-units ...

Lots of compilations trigger this crash, so you may not actually need me to reduce anything, you could maybe try compiling any large codebase (clang+llvm probably works) with those flags and find something. I'm reducing https://github.com/abseil/abseil-cpp/blob/master/absl/strings/str_split.cc which is the earliest failure seen.

jmorse added a comment.Feb 2 2021, 1:16 PM

Hi,

While I'm reducing the source, the minimal flags to hit this seem to be clang -g -mllvm -generate-type-units ...

Ah, generate-type-units is the key, I generate a bunch of assertion failures on a stage2 RelWithDebInfo build and that flag:

Unknown DIE kind
UNREACHABLE executed at /fast/fs/llvm4/llvm/lib/CodeGen/AsmPrinter/DIE.cpp:347!

I'll start digging into that, thanks for the flags.

llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp