[PATCH] D108271: [NFC][DebugInfo] getDwarfCompileUnitID

Kyungwoo Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 17 23:04:05 PDT 2021


kyulee created this revision.
Herald added a subscriber: hiraditya.
kyulee requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a refactoring for the use in https://reviews.llvm.org/D108261


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108271

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h


Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -612,7 +612,7 @@
                          DenseSet<InlinedEntity> &ProcessedVars);
 
   /// Build the location list for all DBG_VALUEs in the
-  /// function that describe the same variable. If the resulting 
+  /// function that describe the same variable. If the resulting
   /// list has only one entry that is valid for entire variable's
   /// scope return true.
   bool buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
@@ -632,6 +632,9 @@
   /// Gather and emit post-function debug information.
   void endFunctionImpl(const MachineFunction *MF) override;
 
+  /// Get Dwarf compile unit ID.
+  unsigned getDwarfCompileUnitID(const DwarfCompileUnit &CU);
+
   void skippedNonDebugFunction() override;
 
 public:
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2147,18 +2147,23 @@
 
   DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
 
+  Asm->OutStreamer->getContext().setDwarfCompileUnitID(
+      getDwarfCompileUnitID(CU));
+
+  // Record beginning of function.
+  PrologEndLoc = emitInitialLocDirective(
+      *MF, Asm->OutStreamer->getContext().getDwarfCompileUnitID());
+}
+
+unsigned DwarfDebug::getDwarfCompileUnitID(const DwarfCompileUnit &CU) {
   // Set DwarfDwarfCompileUnitID in MCContext to the Compile Unit this function
   // belongs to so that we add to the correct per-cu line table in the
   // non-asm case.
   if (Asm->OutStreamer->hasRawTextSupport())
     // Use a single line table if we are generating assembly.
-    Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
+    return 0;
   else
-    Asm->OutStreamer->getContext().setDwarfCompileUnitID(CU.getUniqueID());
-
-  // Record beginning of function.
-  PrologEndLoc = emitInitialLocDirective(
-      *MF, Asm->OutStreamer->getContext().getDwarfCompileUnitID());
+    return CU.getUniqueID();
 }
 
 void DwarfDebug::skippedNonDebugFunction() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108271.367118.patch
Type: text/x-patch
Size: 2245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210818/ce34136e/attachment.bin>


More information about the llvm-commits mailing list