diff options
| author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-11-14 14:42:01 +0000 |
|---|---|---|
| committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-11-19 11:23:11 +0000 |
| commit | a89ca4ae179def7fac1a35e53d7b28d4c9d531be (patch) | |
| tree | 91d45798b1ac784caaca66465c4522fef3e6bcb9 /llvm/lib/CodeGen | |
| parent | 7deb8ce4c161e9715181bd3618f059e8a4a742bb (diff) | |
| download | bcm5719-llvm-a89ca4ae179def7fac1a35e53d7b28d4c9d531be.tar.gz bcm5719-llvm-a89ca4ae179def7fac1a35e53d7b28d4c9d531be.zip | |
Fix PR44001: assert failure in getFunctionLocalOffsetAfterInsn
Summary:
Assert in getFunctionLocalOffsetAfterInsn() fails when processing a call
MachineInstr inside a bundle and compiling with debug info. This is
because labels are added by DwarfDebug::beginInstruction() which is
called for each top-level MI by EmitFunctionBody()'s for-loop iteration
but constructCallSiteEntryDIEs() which calls
getFunctionLocalOffsetAfterInsn() iterates over all MIs.
This commit modifies constructCallSiteEntryDIEs() to get the associated
bundle MI for call MIs inside a bundle and use that to when calling
getFunctionLocalOffsetAfterInsn() and getLabelAfterInsn(). It also skips
loop iterations for bundle MIs since the loop statements are concerned
with debug info for each physical instructions and bundles represent a
group of instructions. It also fix the comment about PCAddr since the
code is getting the return address and not the call address.
Reviewers: dstenb, vsk, aprantl, djtodoro, dblaikie, NikolaPrica
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70293
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d9b5eb1d6d0..84444ca5174 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -714,6 +714,12 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP, // Emit call site entries for each call or tail call in the function. for (const MachineBasicBlock &MBB : MF) { for (const MachineInstr &MI : MBB.instrs()) { + // Bundles with call in them will pass the isCall() test below but do not + // have callee operand information so skip them here. Iterator will + // eventually reach the call MI. + if (MI.isBundle()) + continue; + // Skip instructions which aren't calls. Both calls and tail-calling jump // instructions (e.g TAILJMPd64) are classified correctly here. if (!MI.isCall()) @@ -748,19 +754,28 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP, bool IsTail = TII->isTailCall(MI); + // If MI is in a bundle, the label was created after the bundle since + // EmitFunctionBody iterates over top-level MIs. Get that top-level MI + // to search for that label below. + const MachineInstr *TopLevelCallMI = + MI.isInsideBundle() ? &*getBundleStart(MI.getIterator()) : &MI; + // For tail calls, for non-gdb tuning, no return PC information is needed. // For regular calls (and tail calls in GDB tuning), the return PC // is needed to disambiguate paths in the call graph which could lead to // some target function. const MCExpr *PCOffset = - (IsTail && !tuneForGDB()) ? nullptr - : getFunctionLocalOffsetAfterInsn(&MI); + (IsTail && !tuneForGDB()) + ? nullptr + : getFunctionLocalOffsetAfterInsn(TopLevelCallMI); - // Address of a call-like instruction for a normal call or a jump-like - // instruction for a tail call. This is needed for GDB + DWARF 4 tuning. + // Return address of a call-like instruction for a normal call or a + // jump-like instruction for a tail call. This is needed for + // GDB + DWARF 4 tuning. const MCSymbol *PCAddr = - ApplyGNUExtensions ? const_cast<MCSymbol*>(getLabelAfterInsn(&MI)) - : nullptr; + ApplyGNUExtensions + ? const_cast<MCSymbol *>(getLabelAfterInsn(TopLevelCallMI)) + : nullptr; assert((IsTail || PCOffset || PCAddr) && "Call without return PC information"); |

