Find enclosing subprogram info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83922 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-10-12 23:11:24 +00:00
parent 1f03471a2d
commit 6ef7517314

View File

@ -1894,6 +1894,24 @@ bool DwarfDebug::ExtractScopeInformation(MachineFunction *MF) {
return !DbgScopeMap.empty();
}
static DISubprogram getDISubprogram(MDNode *N) {
DIDescriptor D(N);
if (D.isNull())
return DISubprogram();
if (D.isCompileUnit())
return DISubprogram();
if (D.isSubprogram())
return DISubprogram(N);
if (D.isLexicalBlock())
return getDISubprogram(DILexicalBlock(N).getContext().getNode());
assert (0 && "Unexpected Descriptor!");
}
/// BeginFunction - Gather pre-function debug information. Assumes being
/// emitted immediately after the function entry point.
void DwarfDebug::BeginFunction(MachineFunction *MF) {
@ -1923,7 +1941,7 @@ void DwarfDebug::BeginFunction(MachineFunction *MF) {
if (!FDL.isUnknown()) {
DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
unsigned LabelID = 0;
DISubprogram SP(DLT.CompileUnit);
DISubprogram SP = getDISubprogram(DLT.CompileUnit);
if (!SP.isNull())
LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.CompileUnit);
else