Skip to content

Commit a77d3e0

Browse files
committed
DWARF: Simplify the way the return PC is attached to call site tags, NFC
This cleanup was suggested by Djordje in D72489. (cherry picked from commit 4346450)
1 parent 51bd4c2 commit a77d3e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ DwarfCompileUnit::getDwarf5OrGNUAttr(dwarf::Attribute Attr) const {
934934
case dwarf::DW_AT_call_origin:
935935
return dwarf::DW_AT_abstract_origin;
936936
case dwarf::DW_AT_call_pc:
937+
case dwarf::DW_AT_call_return_pc:
937938
return dwarf::DW_AT_low_pc;
938939
case dwarf::DW_AT_call_value:
939940
return dwarf::DW_AT_GNU_call_site_value;
@@ -982,12 +983,13 @@ DIE &DwarfCompileUnit::constructCallSiteEntryDIE(DIE &ScopeDIE,
982983

983984
// Attach the return PC to allow the debugger to disambiguate call paths
984985
// from one function to another.
985-
if (DD->getDwarfVersion() == 4 && DD->tuneForGDB()) {
986-
assert(PCAddr && "Missing PC information for a call");
987-
addLabelAddress(CallSiteDIE, dwarf::DW_AT_low_pc, PCAddr);
988-
} else if (!IsTail || DD->tuneForGDB()) {
986+
//
987+
// The return PC is only really needed when the call /isn't/ a tail call, but
988+
// for some reason GDB always expects it.
989+
if (!IsTail || DD->tuneForGDB()) {
989990
assert(PCAddr && "Missing return PC information for a call");
990-
addLabelAddress(CallSiteDIE, dwarf::DW_AT_call_return_pc, PCAddr);
991+
addLabelAddress(CallSiteDIE,
992+
getDwarf5OrGNUAttr(dwarf::DW_AT_call_return_pc), PCAddr);
991993
}
992994

993995
return CallSiteDIE;

0 commit comments

Comments
 (0)