This is somewhat déjà-vu, but avoid using getCompileUnit() as much as possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2011-08-15 22:24:32 +00:00
parent 3d30b435e2
commit d30243402b
2 changed files with 14 additions and 14 deletions

View File

@ -182,8 +182,8 @@ static StringRef getRealLinkageName(StringRef LinkageName) {
/// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes. /// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
/// If there are global variables in this scope then create and insert /// If there are global variables in this scope then create and insert
/// DIEs for these variables. /// DIEs for these variables.
DIE *DwarfDebug::updateSubprogramScopeDIE(const MDNode *SPNode) { DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU,
CompileUnit *SPCU = getCompileUnit(SPNode); const MDNode *SPNode) {
DIE *SPDie = SPCU->getDIE(SPNode); DIE *SPDie = SPCU->getDIE(SPNode);
assert(SPDie && "Unable to find subprogram DIE!"); assert(SPDie && "Unable to find subprogram DIE!");
@ -246,7 +246,8 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(const MDNode *SPNode) {
/// constructLexicalScope - Construct new DW_TAG_lexical_block /// constructLexicalScope - Construct new DW_TAG_lexical_block
/// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels. /// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
DIE *DwarfDebug::constructLexicalScopeDIE(LexicalScope *Scope) { DIE *DwarfDebug::constructLexicalScopeDIE(CompileUnit *TheCU,
LexicalScope *Scope) {
DIE *ScopeDIE = new DIE(dwarf::DW_TAG_lexical_block); DIE *ScopeDIE = new DIE(dwarf::DW_TAG_lexical_block);
if (Scope->isAbstractScope()) if (Scope->isAbstractScope())
@ -256,7 +257,6 @@ DIE *DwarfDebug::constructLexicalScopeDIE(LexicalScope *Scope) {
if (Ranges.empty()) if (Ranges.empty())
return 0; return 0;
CompileUnit *TheCU = getCompileUnit(Scope->getScopeNode());
SmallVector<InsnRange, 4>::const_iterator RI = Ranges.begin(); SmallVector<InsnRange, 4>::const_iterator RI = Ranges.begin();
if (Ranges.size() > 1) { if (Ranges.size() > 1) {
// .debug_range section has not been laid out yet. Emit offset in // .debug_range section has not been laid out yet. Emit offset in
@ -292,7 +292,8 @@ DIE *DwarfDebug::constructLexicalScopeDIE(LexicalScope *Scope) {
/// constructInlinedScopeDIE - This scope represents inlined body of /// constructInlinedScopeDIE - This scope represents inlined body of
/// a function. Construct DIE to represent this concrete inlined copy /// a function. Construct DIE to represent this concrete inlined copy
/// of the function. /// of the function.
DIE *DwarfDebug::constructInlinedScopeDIE(LexicalScope *Scope) { DIE *DwarfDebug::constructInlinedScopeDIE(CompileUnit *TheCU,
LexicalScope *Scope) {
const SmallVector<InsnRange, 4> &Ranges = Scope->getRanges(); const SmallVector<InsnRange, 4> &Ranges = Scope->getRanges();
assert (Ranges.empty() == false assert (Ranges.empty() == false
@ -302,7 +303,6 @@ DIE *DwarfDebug::constructInlinedScopeDIE(LexicalScope *Scope) {
return NULL; return NULL;
DIScope DS(Scope->getScopeNode()); DIScope DS(Scope->getScopeNode());
DISubprogram InlinedSP = getDISubprogram(DS); DISubprogram InlinedSP = getDISubprogram(DS);
CompileUnit *TheCU = getCompileUnit(InlinedSP);
DIE *OriginDIE = TheCU->getDIE(InlinedSP); DIE *OriginDIE = TheCU->getDIE(InlinedSP);
if (!OriginDIE) { if (!OriginDIE) {
DEBUG(dbgs() << "Unable to find original DIE for inlined subprogram."); DEBUG(dbgs() << "Unable to find original DIE for inlined subprogram.");
@ -399,23 +399,23 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
DIScope DS(Scope->getScopeNode()); DIScope DS(Scope->getScopeNode());
DIE *ScopeDIE = NULL; DIE *ScopeDIE = NULL;
if (Scope->getInlinedAt()) if (Scope->getInlinedAt())
ScopeDIE = constructInlinedScopeDIE(Scope); ScopeDIE = constructInlinedScopeDIE(TheCU, Scope);
else if (DS.isSubprogram()) { else if (DS.isSubprogram()) {
ProcessedSPNodes.insert(DS); ProcessedSPNodes.insert(DS);
if (Scope->isAbstractScope()) { if (Scope->isAbstractScope()) {
ScopeDIE = getCompileUnit(DS)->getDIE(DS); ScopeDIE = TheCU->getDIE(DS);
// Note down abstract DIE. // Note down abstract DIE.
if (ScopeDIE) if (ScopeDIE)
AbstractSPDies.insert(std::make_pair(DS, ScopeDIE)); AbstractSPDies.insert(std::make_pair(DS, ScopeDIE));
} }
else else
ScopeDIE = updateSubprogramScopeDIE(DS); ScopeDIE = updateSubprogramScopeDIE(TheCU, DS);
} }
else { else {
// There is no need to emit empty lexical block DIE. // There is no need to emit empty lexical block DIE.
if (Children.empty()) if (Children.empty())
return NULL; return NULL;
ScopeDIE = constructLexicalScopeDIE(Scope); ScopeDIE = constructLexicalScopeDIE(TheCU, Scope);
} }
if (!ScopeDIE) return NULL; if (!ScopeDIE) return NULL;
@ -426,7 +426,7 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
ScopeDIE->addChild(*I); ScopeDIE->addChild(*I);
if (DS.isSubprogram()) if (DS.isSubprogram())
getCompileUnit(DS)->addPubTypes(DISubprogram(DS)); TheCU->addPubTypes(DISubprogram(DS));
return ScopeDIE; return ScopeDIE;
} }

View File

@ -314,16 +314,16 @@ private:
/// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes. /// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
/// If there are global variables in this scope then create and insert /// If there are global variables in this scope then create and insert
/// DIEs for these variables. /// DIEs for these variables.
DIE *updateSubprogramScopeDIE(const MDNode *SPNode); DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, const MDNode *SPNode);
/// constructLexicalScope - Construct new DW_TAG_lexical_block /// constructLexicalScope - Construct new DW_TAG_lexical_block
/// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels. /// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
DIE *constructLexicalScopeDIE(LexicalScope *Scope); DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
/// constructInlinedScopeDIE - This scope represents inlined body of /// constructInlinedScopeDIE - This scope represents inlined body of
/// a function. Construct DIE to represent this concrete inlined copy /// a function. Construct DIE to represent this concrete inlined copy
/// of the function. /// of the function.
DIE *constructInlinedScopeDIE(LexicalScope *Scope); DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
/// constructVariableDIE - Construct a DIE for the given DbgVariable. /// constructVariableDIE - Construct a DIE for the given DbgVariable.
DIE *constructVariableDIE(DbgVariable *DV, LexicalScope *S); DIE *constructVariableDIE(DbgVariable *DV, LexicalScope *S);