diff options
author | Vedant Kumar <vsk@apple.com> | 2018-10-22 21:44:21 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-10-22 21:44:21 +0000 |
commit | 74533bd3b80c9e57940e06579b162c7db67d5b9d (patch) | |
tree | 7e450efbe51936dfecb72196af0a0d837f09f476 /llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | |
parent | dd1c3df72d33c426d08d20dc0f08b53a9075a7d4 (diff) | |
download | llvm-74533bd3b80c9e57940e06579b162c7db67d5b9d.zip llvm-74533bd3b80c9e57940e06579b162c7db67d5b9d.tar.gz llvm-74533bd3b80c9e57940e06579b162c7db67d5b9d.tar.bz2 |
[DWARF] Use a function-local offset for AT_call_return_pc
Logs provided by @stella.stamenova indicate that on Linux, lldb adds a
spurious slide offset to the return PC it loads from AT_call_return_pc
attributes (see the list thread: "[PATCH] D50478: Add support for
artificial tail call frames").
This patch side-steps the issue by getting rid of the load address
calculation in lldb's CallEdge::GetReturnPCAddress.
The idea is to have the DWARF writer emit function-local offsets to the
instruction after a call. I.e. return-pc = label-after-call-insn -
function-entry. LLDB can simply add this offset to the base address of a
function to get the return PC.
Differential Revision: https://reviews.llvm.org/D53469
llvm-svn: 344960
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 81eb0c2..1d9c1d3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -821,7 +821,7 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE( DIE &DwarfCompileUnit::constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram &CalleeSP, bool IsTail, - const MCSymbol *ReturnPC) { + const MCExpr *PCOffset) { // Insert a call site entry DIE within ScopeDIE. DIE &CallSiteDIE = createAndAddDIE(dwarf::DW_TAG_call_site, ScopeDIE, nullptr); @@ -838,8 +838,8 @@ DIE &DwarfCompileUnit::constructCallSiteEntryDIE(DIE &ScopeDIE, } else { // Attach the return PC to allow the debugger to disambiguate call paths // from one function to another. - assert(ReturnPC && "Missing return PC information for a call"); - addLabelAddress(CallSiteDIE, dwarf::DW_AT_call_return_pc, ReturnPC); + assert(PCOffset && "Missing return PC information for a call"); + addAddressExpr(CallSiteDIE, dwarf::DW_AT_call_return_pc, PCOffset); } return CallSiteDIE; } @@ -1103,6 +1103,12 @@ void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form, Die.addValue(DIEValueAllocator, (dwarf::Attribute)0, Form, DIEExpr(Expr)); } +void DwarfCompileUnit::addAddressExpr(DIE &Die, dwarf::Attribute Attribute, + const MCExpr *Expr) { + Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_addr, + DIEExpr(Expr)); +} + void DwarfCompileUnit::applySubprogramAttributesToDefinition( const DISubprogram *SP, DIE &SPDie) { auto *SPDecl = SP->getDeclaration(); |