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

Devang Patel dpatel at apple.com
Mon Aug 8 11:22:10 PDT 2011


Author: dpatel
Date: Mon Aug  8 13:22:10 2011
New Revision: 137056

URL: http://llvm.org/viewvc/llvm-project?rev=137056&view=rev
Log:
Simplify by creating parent first.

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=137056&r1=137055&r2=137056&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug  8 13:22:10 2011
@@ -149,12 +149,14 @@
   DbgScope(DbgScope *P, DIDescriptor D, const MDNode *I = 0)
     : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(false),
       LastInsn(0), FirstInsn(0),
-      DFSIn(0), DFSOut(0), IndentLevel(0) {}
+      DFSIn(0), DFSOut(0), IndentLevel(0) {
+    if (Parent)
+      Parent->addScope(this);
+  }
   virtual ~DbgScope();
 
   // Accessors.
   DbgScope *getParent()          const { return Parent; }
-  void setParent(DbgScope *P)          { Parent = P; }
   DIDescriptor getDesc()         const { return Desc; }
   const MDNode *getInlinedAt()         const { return InlinedAtLocation; }
   const MDNode *getScopeNode()         const { return Desc; }
@@ -421,11 +423,7 @@
     DIDescriptor ParentDesc = DB.getContext();
     Parent = getOrCreateAbstractScope(ParentDesc);
   }
-
   AScope = new DbgScope(Parent, DIDescriptor(N), NULL);
-
-  if (Parent)
-    Parent->addScope(AScope);
   AScope->setAbstractScope();
   AbstractScopes[N] = AScope;
   if (DIDescriptor(N).isSubprogram())
@@ -1590,17 +1588,16 @@
 /// getOrCreateRegularScope - Create regular DbgScope.
 DbgScope *DwarfDebug::getOrCreateRegularScope(MDNode *Scope) {
   DbgScope *WScope = DbgScopeMap.lookup(Scope);
-  if (WScope)
+  if (WScope) 
     return WScope;
-  WScope = new DbgScope(NULL, DIDescriptor(Scope), NULL);
+
+  DbgScope *Parent = NULL;
+  if (DIDescriptor(Scope).isLexicalBlock())
+    Parent = getOrCreateDbgScope(DebugLoc::getFromDILexicalBlock(Scope));
+  WScope = new DbgScope(Parent, 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()))
+  if (!Parent && DIDescriptor(Scope).isSubprogram()
+      && DISubprogram(Scope).describes(Asm->MF->getFunction()))
     CurrentFnDbgScope = WScope;
   
   return WScope;
@@ -1612,13 +1609,11 @@
   if (InlinedScope)
     return InlinedScope;
 
-  InlinedScope = new DbgScope(NULL, DIDescriptor(Scope), InlinedAt);
   DebugLoc InlinedLoc = DebugLoc::getFromDILocation(InlinedAt);
+  InlinedScope = new DbgScope(getOrCreateDbgScope(InlinedLoc),
+                              DIDescriptor(Scope), InlinedAt);
   InlinedDbgScopeMap[InlinedLoc] = InlinedScope;
   DbgScopeMap[InlinedAt] = InlinedScope;
-  DbgScope *Parent = getOrCreateDbgScope(InlinedLoc);
-  InlinedScope->setParent(Parent);
-  Parent->addScope(InlinedScope);
   return InlinedScope;
 }
 





More information about the llvm-commits mailing list