[llvm] a95b212 - [DWARF] Don't search scope chain to find DISubprogram for prologues (#107261)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 02:34:37 PDT 2024


Author: Jeremy Morse
Date: 2024-09-05T10:34:34+01:00
New Revision: a95b212e9957b8f5b7d452b4713a7b6f9ee19e71

URL: https://github.com/llvm/llvm-project/commit/a95b212e9957b8f5b7d452b4713a7b6f9ee19e71
DIFF: https://github.com/llvm/llvm-project/commit/a95b212e9957b8f5b7d452b4713a7b6f9ee19e71.diff

LOG: [DWARF] Don't search scope chain to find DISubprogram for prologues (#107261)

Seemingly this goes back to fd07a2a in 2015 -- I anticipate that back
then the metadata layout was radically different. But nowadays at least, we
can just directly look up the subprogram.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 77e304383fb5c7..9da9382baf8634 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2198,11 +2198,10 @@ DebugLoc DwarfDebug::emitInitialLocDirective(const MachineFunction &MF,
 
     // Ensure the compile unit is created if the function is called before
     // beginFunction().
-    (void)getOrCreateDwarfCompileUnit(
-        MF.getFunction().getSubprogram()->getUnit());
+    DISubprogram *SP = MF.getFunction().getSubprogram();
+    (void)getOrCreateDwarfCompileUnit(SP->getUnit());
     // We'd like to list the prologue as "not statements" but GDB behaves
     // poorly if we do that. Revisit this with caution/GDB (7.5+) testing.
-    const DISubprogram *SP = PrologEndLoc->getInlinedAtScope()->getSubprogram();
     ::recordSourceLine(*Asm, SP->getScopeLine(), 0, SP, DWARF2_FLAG_IS_STMT,
                        CUID, getDwarfVersion(), getUnits());
     return PrologEndLoc;


        


More information about the llvm-commits mailing list