diff options
author | Devang Patel <dpatel@apple.com> | 2011-08-08 18:22:10 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-08-08 18:22:10 +0000 |
commit | c0405292693dc463cd14ce20b3ead7dcd1260e8e (patch) | |
tree | dd63499b84f671d5363ac2f220ace967b682b624 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | 66b0f515d5f7d4b830c3407a273facde405e4f86 (diff) | |
download | external_llvm-c0405292693dc463cd14ce20b3ead7dcd1260e8e.zip external_llvm-c0405292693dc463cd14ce20b3ead7dcd1260e8e.tar.gz external_llvm-c0405292693dc463cd14ce20b3ead7dcd1260e8e.tar.bz2 |
Simplify by creating parent first.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 0a3f750..20507f5 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -149,12 +149,14 @@ public: 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 @@ DbgScope *DwarfDebug::getOrCreateAbstractScope(const MDNode *N) { 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 @@ void DwarfDebug::endInstruction(const MachineInstr *MI) { /// 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 @@ DbgScope *DwarfDebug::getOrCreateInlinedScope(MDNode *Scope, MDNode *InlinedAt){ 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; } |