[PATCH] D135114: [Dwarf] Reference the correct CU when inlining

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 15:51:07 PDT 2022


ellis created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
ellis edited the summary of this revision.
ellis added reviewers: kyulee, dblaikie, krisb, dexonsmith, aprantl.
ellis published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Sometimes when a function is inlined into a different CU, `llvm-dwarfdump --verify` would find an inlined subroutine with an invalid abstract origin. This is because `DwarfUnit::addDIEEntry()` will incorrectly assume the inlined subroutine and the abstract origin are from the same CU if it can't find the CU for the inlined subroutine.

In the added test, the inlined subroutine for `bar()` is created before the CU for `B.swift` is created, so it tries to point to `goo()` in the wrong CU. Interestingly, if we swap the order of the two functions then we don't see a crash since the module for `goo()` is created first.

The fix is to give a parent DIE to `ScopeDIE` before calling `addDIEEntry()` so that its CU can be found. Luckily, `constructInlinedScopeDIE()` is only called once so we can pass it the DIE of the scope's parent and give it a child just after it's created.

`constructInlinedScopeDIE()` should always return a DIE, so assert that it is not null.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135114

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/test/DebugInfo/dwarfdump-inlined.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135114.464839.patch
Type: text/x-patch
Size: 5516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221003/411edef4/attachment.bin>


More information about the llvm-commits mailing list