diff options
author | Devang Patel <dpatel@apple.com> | 2011-07-20 23:00:27 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-07-20 23:00:27 +0000 |
commit | ddfe66e9484ddf6f45a4dc3977bac13171f84eaa (patch) | |
tree | 9674d03afca9b42f148c88760053d4b69b5ceb4c | |
parent | 5d2a7328edbd15d1a086a6ba99953f53098a1e3f (diff) | |
download | bcm5719-llvm-ddfe66e9484ddf6f45a4dc3977bac13171f84eaa.tar.gz bcm5719-llvm-ddfe66e9484ddf6f45a4dc3977bac13171f84eaa.zip |
Refactor.
llvm-svn: 135633
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 70 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 3 |
2 files changed, 42 insertions, 31 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 30d63991ea0..696f72b8d5c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1573,44 +1573,54 @@ void DwarfDebug::endInstruction(const MachineInstr *MI) { 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 diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 32006a39431..30ba0b3bb15 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -318,7 +318,8 @@ private: /// 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. |