Continue to hoist uses of getCompileUnit() up. The goal is to get rid of uses of getCompileUnit().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137683 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2011-08-15 23:36:40 +00:00
parent e17a14e2de
commit 3655a21b15
2 changed files with 24 additions and 21 deletions

View File

@ -539,28 +539,22 @@ CompileUnit *DwarfDebug::getCompileUnit(const MDNode *N) const {
}
/// constructGlobalVariableDIE - Construct global variable DIE.
void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
void DwarfDebug::constructGlobalVariableDIE(CompileUnit *TheCU,
const MDNode *N) {
DIGlobalVariable GV(N);
// If debug information is malformed then ignore it.
if (GV.Verify() == false)
return;
// Check for pre-existence.
CompileUnit *TheCU = getCompileUnit(N);
TheCU->createGlobalVariableDIE(N);
return;
}
/// construct SubprogramDIE - Construct subprogram DIE.
void DwarfDebug::constructSubprogramDIE(const MDNode *N) {
void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
const MDNode *N) {
DISubprogram SP(N);
// Check for pre-existence.
CompileUnit *TheCU = getCompileUnit(N);
if (TheCU->getDIE(N))
return;
if (!SP.isDefinition())
// This is a method declaration which will be handled while constructing
// class type.
@ -603,12 +597,16 @@ void DwarfDebug::beginModule(Module *M) {
constructCompileUnit(CU_Nodes->getOperand(i));
if (GV_Nodes)
for (unsigned i = 0, e = GV_Nodes->getNumOperands(); i != e; ++i)
constructGlobalVariableDIE(GV_Nodes->getOperand(i));
for (unsigned i = 0, e = GV_Nodes->getNumOperands(); i != e; ++i) {
const MDNode *N = GV_Nodes->getOperand(i);
constructGlobalVariableDIE(getCompileUnit(N), N);
}
if (SP_Nodes)
for (unsigned i = 0, e = SP_Nodes->getNumOperands(); i != e; ++i)
constructSubprogramDIE(SP_Nodes->getOperand(i));
for (unsigned i = 0, e = SP_Nodes->getNumOperands(); i != e; ++i) {
const MDNode *N = SP_Nodes->getOperand(i);
constructSubprogramDIE(getCompileUnit(N), N);
}
} else {
@ -634,13 +632,18 @@ void DwarfDebug::beginModule(Module *M) {
// Create DIEs for each global variable.
for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(),
E = DbgFinder.global_variable_end(); I != E; ++I)
constructGlobalVariableDIE(*I);
E = DbgFinder.global_variable_end(); I != E; ++I) {
const MDNode *N = *I;
if (DIGlobalVariable(N).getVersion() <= LLVMDebugVersion9)
constructGlobalVariableDIE(getCompileUnit(N), N);
}
// Create DIEs for each subprogram.
for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
E = DbgFinder.subprogram_end(); I != E; ++I)
constructSubprogramDIE(*I);
E = DbgFinder.subprogram_end(); I != E; ++I) {
const MDNode *N = *I;
constructSubprogramDIE(getCompileUnit(N), N);
}
}
// Tell MMI that we have debug info.
@ -698,8 +701,8 @@ void DwarfDebug::endModule() {
}
// Construct subprogram DIE and add variables DIEs.
constructSubprogramDIE(SP);
CompileUnit *SPCU = getCompileUnit(SP);
constructSubprogramDIE(SPCU, SP);
DIE *ScopeDIE = SPCU->getDIE(SP);
for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
if (DIE *VariableDIE =

View File

@ -416,10 +416,10 @@ private:
CompileUnit *getCompileUnit(const MDNode *N) const;
/// constructGlobalVariableDIE - Construct global variable DIE.
void constructGlobalVariableDIE(const MDNode *N);
void constructGlobalVariableDIE(CompileUnit *TheCU, const MDNode *N);
/// construct SubprogramDIE - Construct subprogram DIE.
void constructSubprogramDIE(const MDNode *N);
void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
/// recordSourceLine - Register a source line with debug info. Returns the
/// unique label that was emitted and which provides correspondence to