aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-10-12 23:11:24 +0000
committerDevang Patel <dpatel@apple.com>2009-10-12 23:11:24 +0000
commit6ef75173142f782b281909125e846f3b6828de98 (patch)
treefbeb3c1b7ba8cd09792e0ecd149c1d13897d3418 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent1f03471a2dfb02fa39f7168244bb8c0891a56ab9 (diff)
Find enclosing subprogram info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f0579fe588..811bf65d9d 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -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