[llvm-commits] [llvm] r135633 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h

Devang Patel dpatel at apple.com
Wed Jul 20 16:00:28 PDT 2011


Author: dpatel
Date: Wed Jul 20 18:00:27 2011
New Revision: 135633

URL: http://llvm.org/viewvc/llvm-project?rev=135633&view=rev
Log:
Refactor.

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=135633&r1=135632&r2=135633&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Jul 20 18:00:27 2011
@@ -1573,44 +1573,54 @@
   I->second = PrevLabel;
 }
 
+/// getOrCreateRegularScope - Create regular DbgScope.
+DbgScope *DwarfDebug::getOrCreateRegularScope(MDNode *Scope) {
+  DbgScope *WScope = DbgScopeMap.lookup(Scope);
+  if (WScope)
+    return WScope;
+  WScope = new DbgScope(NULL, DIDescriptor(Scope), NULL);
+  DbgScopeMap.insert(std::make_pair(Scope, WScope));
+  if (DIDescriptor(Scope).isLexicalBlock()) {
+    DbgScope *Parent =
+      getOrCreateDbgScope(DebugLoc::getFromDILexicalBlock(Scope));
+    WScope->setParent(Parent);
+    Parent->addScope(WScope);
+  } else if (DIDescriptor(Scope).isSubprogram()
+             && DISubprogram(Scope).describes(Asm->MF->getFunction()))
+    CurrentFnDbgScope = WScope;
+  
+  return WScope;
+}
+
+/// getOrCreateInlinedScope - Create inlined scope. 
+DbgScope *DwarfDebug::getOrCreateInlinedScope(MDNode *Scope, MDNode *InlinedAt){
+  DbgScope *InlinedScope = DbgScopeMap.lookup(InlinedAt);
+  if (InlinedScope)
+    return InlinedScope;
+
+  InlinedScope = new DbgScope(NULL, DIDescriptor(Scope), InlinedAt);
+  DebugLoc InlinedLoc = DebugLoc::getFromDILocation(InlinedAt);
+  InlinedDbgScopeMap[InlinedLoc] = InlinedScope;
+  DbgScopeMap[InlinedAt] = InlinedScope;
+  DbgScope *Parent = getOrCreateDbgScope(InlinedLoc);
+  InlinedScope->setParent(Parent);
+  Parent->addScope(InlinedScope);
+  return InlinedScope;
+}
+
 /// getOrCreateDbgScope - Create DbgScope for the scope.
 DbgScope *DwarfDebug::getOrCreateDbgScope(DebugLoc DL) {
   LLVMContext &Ctx = Asm->MF->getFunction()->getContext();
   MDNode *Scope = NULL;
   MDNode *InlinedAt = NULL;
   DL.getScopeAndInlinedAt(Scope, InlinedAt, Ctx);
+  if (!InlinedAt) 
+    return getOrCreateRegularScope(Scope);
 
-  if (!InlinedAt) {
-    DbgScope *WScope = DbgScopeMap.lookup(Scope);
-    if (WScope)
-      return WScope;
-    WScope = new DbgScope(NULL, DIDescriptor(Scope), NULL);
-    DbgScopeMap.insert(std::make_pair(Scope, WScope));
-    if (DIDescriptor(Scope).isLexicalBlock()) {
-      DbgScope *Parent =
-        getOrCreateDbgScope(DebugLoc::getFromDILexicalBlock(Scope));
-      WScope->setParent(Parent);
-      Parent->addScope(WScope);
-    } else if (DIDescriptor(Scope).isSubprogram()
-               && DISubprogram(Scope).describes(Asm->MF->getFunction()))
-      CurrentFnDbgScope = WScope;
-
-    return WScope;
-  }
-
+  // Create an abstract scope for inlined function.
   getOrCreateAbstractScope(Scope);
-  DbgScope *WScope = DbgScopeMap.lookup(InlinedAt);
-  if (WScope)
-    return WScope;
-
-  WScope = new DbgScope(NULL, DIDescriptor(Scope), InlinedAt);
-  DbgScopeMap.insert(std::make_pair(InlinedAt, WScope));
-  InlinedDbgScopeMap[DebugLoc::getFromDILocation(InlinedAt)] = WScope;
-  DbgScope *Parent =
-    getOrCreateDbgScope(DebugLoc::getFromDILocation(InlinedAt));
-  WScope->setParent(Parent);
-  Parent->addScope(WScope);
-  return WScope;
+  // Create an inlined scope for inlined function.
+  return getOrCreateInlinedScope(Scope, InlinedAt);
 }
 
 /// calculateDominanceGraph - Calculate dominance graph for DbgScope

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=135633&r1=135632&r2=135633&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Jul 20 18:00:27 2011
@@ -318,7 +318,8 @@
 
   /// getOrCreateDbgScope - Create DbgScope for the scope.
   DbgScope *getOrCreateDbgScope(DebugLoc DL);
-
+  DbgScope *getOrCreateRegularScope(MDNode *Scope);
+  DbgScope *getOrCreateInlinedScope(MDNode *Scope, MDNode *InlinedAt);
   DbgScope *getOrCreateAbstractScope(const MDNode *N);
 
   /// findAbstractVariable - Find abstract variable associated with Var.





More information about the llvm-commits mailing list