diff options
author | Vedant Kumar <vsk@apple.com> | 2019-11-15 15:37:29 -0800 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2019-12-10 14:00:57 -0800 |
commit | 30038da15b18ac4e34b9ea7a648382ae481e4770 (patch) | |
tree | 70e5cc5c4817b709bea49cb7560dfc33fef9cf48 /llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | |
parent | e8d955f29de7ee4b50d889c418b4efb18add0653 (diff) | |
download | bcm5719-llvm-30038da15b18ac4e34b9ea7a648382ae481e4770.tar.gz bcm5719-llvm-30038da15b18ac4e34b9ea7a648382ae481e4770.zip |
[DWARF] Allow cross-CU references of subprogram definitions
This allows a call site tag in CU A to reference a callee DIE in CU B
without resorting to creating an incomplete duplicate DIE for the callee
inside of CU A.
We already allow cross-CU references of subprogram declarations, so it
doesn't seem like definitions ought to be special.
This improves entry value evaluation and tail call frame synthesis in
the LTO setting. During LTO, it's common for cross-module inlining to
produce a call in some CU A where the callee resides in a different CU,
and there is no declaration subprogram for the callee anywhere. In this
case llvm would (unnecessarily, I think) emit an empty DW_TAG_subprogram
in order to fill in the call site tag. That empty 'definition' defeats
entry value evaluation etc., because the debugger can't figure out what
it means.
As a follow-up, maybe we could add a DWARF verifier check that a
DW_TAG_subprogram at least has a DW_AT_name attribute.
rdar://46577651
Differential Revision: https://reviews.llvm.org/D70350
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 86522a85427..58d7a4eaa7e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -188,8 +188,9 @@ int64_t DwarfUnit::getDefaultLowerBound() const { /// Check whether the DIE for this MDNode can be shared across CUs. bool DwarfUnit::isShareableAcrossCUs(const DINode *D) const { - // When the MDNode can be part of the type system, the DIE can be shared - // across CUs. + // When the MDNode can be part of the type system (this includes subprogram + // declarations *and* subprogram definitions, even local definitions), the + // DIE must be shared across CUs. // Combining type units and cross-CU DIE sharing is lower value (since // cross-CU DIE sharing is used in LTO and removes type redundancy at that // level already) but may be implementable for some value in projects @@ -197,9 +198,7 @@ bool DwarfUnit::isShareableAcrossCUs(const DINode *D) const { // together. if (isDwoUnit() && !DD->shareAcrossDWOCUs()) return false; - return (isa<DIType>(D) || - (isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) && - !DD->generateTypeUnits(); + return (isa<DIType>(D) || isa<DISubprogram>(D)) && !DD->generateTypeUnits(); } DIE *DwarfUnit::getDIE(const DINode *D) const { |