[PATCH] D45037: [DebugInfo] Emit comments for DBG_LABEL in AsmPrinter.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 07:13:51 PDT 2018


HsiangKai created this revision.
HsiangKai added reviewers: rnk, chenwj.
Herald added a subscriber: JDevlieghere.

Repository:
  rL LLVM

https://reviews.llvm.org/D45037

Files:
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp


Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -912,6 +912,31 @@
   return true;
 }
 
+/// emitDebugLabelComment - This method handles the target-independent form
+/// of DBG_LABEL, returning true if it was able to do so.  A false return
+/// means the target will need to handle MI in EmitInstruction.
+static bool emitDebugLabelComment(const MachineInstr *MI, AsmPrinter &AP) {
+  // This code handles only the 1-operand target-independent form.
+  if (MI->getNumOperands() != 1)
+    return false;
+
+  SmallString<128> Str;
+  raw_svector_ostream OS(Str);
+  OS << "DEBUG_LABEL: ";
+
+  const DILabel *V = MI->getDebugLabel();
+  if (auto *SP = dyn_cast<DISubprogram>(V->getScope())) {
+    StringRef Name = SP->getName();
+    if (!Name.empty())
+      OS << Name << ":";
+  }
+  OS << V->getName();
+
+  // NOTE: Want this comment at start of line, don't emit with AddComment.
+  AP.OutStreamer->emitRawComment(OS.str());
+  return true;
+}
+
 AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() const {
   if (MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI &&
       MF->getFunction().needsUnwindTableEntry())
@@ -1057,6 +1082,12 @@
             EmitInstruction(&MI);
         }
         break;
+      case TargetOpcode::DBG_LABEL:
+	if (isVerbose()) {
+	  if (!emitDebugLabelComment(&MI, *this))
+	    EmitInstruction(&MI);
+	}
+	break;
       case TargetOpcode::IMPLICIT_DEF:
         if (isVerbose()) emitImplicitDef(&MI);
         break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45037.140239.patch
Type: text/x-patch
Size: 1618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/8e6c97bf/attachment.bin>


More information about the llvm-commits mailing list