From cdec7448698d8dfb20992309b7310c9bb0e97150 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 13 May 2009 23:55:49 +0000 Subject: [PATCH] There's yet more ugliness (surprise!) in DebugInfo. This needs major reworking. Basically, there was a situation where it was getting an empty vector and doing a .back() on that. Which isn't cool. llvm-svn: 71746 --- llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 51 ++++++++++++--------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 35539011aad4..bc83b8f026dc 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1286,9 +1286,14 @@ class DwarfDebug : public Dwarf { /// DbgScopeMap - Tracks the scopes in the current function. DenseMap DbgScopeMap; - /// DbgInlinedScopeMap - Tracks inlined scopes in the current function. + /// DbgAbstractScopeMap - Tracks abstract instance scopes in the current + /// function. + DenseMap DbgAbstractScopeMap; + + /// DbgConcreteScopeMap - Tracks concrete instance scopes in the current + /// function. DenseMap > DbgInlinedScopeMap; + SmallVector > DbgConcreteScopeMap; /// InlineInfo - Keep track of inlined functions and their location. This /// information is used to populate debug_inlined section. @@ -3434,7 +3439,8 @@ public: if (FunctionDbgScope) { delete FunctionDbgScope; DbgScopeMap.clear(); - DbgInlinedScopeMap.clear(); + DbgAbstractScopeMap.clear(); + DbgConcreteScopeMap.clear(); InlinedVariableScopes.clear(); FunctionDbgScope = NULL; LexicalScopeStack.clear(); @@ -3578,7 +3584,7 @@ public: } } - assert(Scope && "Unable to find variable' scope"); + assert(Scope && "Unable to find the variable's scope"); DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex); Scope->AddVariable(DV); @@ -3619,14 +3625,8 @@ public: // could be more elegant. AddUInt(SPDie, DW_AT_inline, 0, DW_INL_declared_not_inlined); - // Keep track of the scope that's inlined into this function. - DenseMap >::iterator - SI = DbgInlinedScopeMap.find(GV); - - if (SI == DbgInlinedScopeMap.end()) - DbgInlinedScopeMap[GV].push_back(Scope); - else - SI->second.push_back(Scope); + // Keep track of the abstract scope for this function. + DbgAbstractScopeMap[GV] = Scope; AbstractInstanceRootMap[GV] = Scope; AbstractInstanceRootList.push_back(Scope); @@ -3650,6 +3650,15 @@ public: LexicalScopeStack.back()->AddConcreteInst(ConcreteScope); + // Keep track of the concrete scope that's inlined into this function. + DenseMap >::iterator + SI = DbgConcreteScopeMap.find(GV); + + if (SI == DbgConcreteScopeMap.end()) + DbgConcreteScopeMap[GV].push_back(ConcreteScope); + else + SI->second.push_back(ConcreteScope); + // Track the start label for this inlined function. DenseMap >::iterator I = InlineInfo.find(GV); @@ -3675,9 +3684,9 @@ public: GlobalVariable *GV = SP.getGV(); DenseMap >::iterator - I = DbgInlinedScopeMap.find(GV); + I = DbgConcreteScopeMap.find(GV); - if (I == DbgInlinedScopeMap.end()) { + if (I == DbgConcreteScopeMap.end()) { if (TimePassesIsEnabled) DebugTimer->stopTimer(); @@ -3698,9 +3707,9 @@ public: } /// RecordVariableScope - Record scope for the variable declared by - /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. - /// Record scopes for only inlined subroutine variables. Other - /// variables' scopes are determined during RecordVariable(). + /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes + /// for only inlined subroutine variables. Other variables's scopes are + /// determined during RecordVariable(). void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI) { if (TimePassesIsEnabled) DebugTimer->startTimer(); @@ -3714,10 +3723,10 @@ public: return; } - DenseMap >::iterator - I = DbgInlinedScopeMap.find(SP.getGV()); - if (I != DbgInlinedScopeMap.end()) - InlinedVariableScopes[DeclareMI] = I->second.back(); + DenseMap::iterator + I = DbgAbstractScopeMap.find(SP.getGV()); + if (I != DbgAbstractScopeMap.end()) + InlinedVariableScopes[DeclareMI] = I->second; if (TimePassesIsEnabled) DebugTimer->stopTimer();