[llvm-commits] [llvm] r83922 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Devang Patel dpatel at apple.com
Mon Oct 12 16:11:24 PDT 2009


Author: dpatel
Date: Mon Oct 12 18:11:24 2009
New Revision: 83922

URL: http://llvm.org/viewvc/llvm-project?rev=83922&view=rev
Log:
Find enclosing subprogram info.

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=83922&r1=83921&r2=83922&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Oct 12 18:11:24 2009
@@ -1894,6 +1894,24 @@
   return !DbgScopeMap.empty();
 }
 
+static DISubprogram getDISubprogram(MDNode *N) {
+
+  DIDescriptor D(N);
+  if (D.isNull())
+    return DISubprogram();
+
+  if (D.isCompileUnit()) 
+    return DISubprogram();
+
+  if (D.isSubprogram())
+    return DISubprogram(N);
+
+  if (D.isLexicalBlock())
+    return getDISubprogram(DILexicalBlock(N).getContext().getNode());
+
+  assert (0 && "Unexpected Descriptor!");
+}
+
 /// BeginFunction - Gather pre-function debug information.  Assumes being
 /// emitted immediately after the function entry point.
 void DwarfDebug::BeginFunction(MachineFunction *MF) {
@@ -1923,7 +1941,7 @@
   if (!FDL.isUnknown()) {
     DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
     unsigned LabelID = 0;
-    DISubprogram SP(DLT.CompileUnit);
+    DISubprogram SP = getDISubprogram(DLT.CompileUnit);
     if (!SP.isNull())
       LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.CompileUnit);
     else





More information about the llvm-commits mailing list