summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-01-20 02:05:23 +0000
committerDevang Patel <dpatel@apple.com>2010-01-20 02:05:23 +0000
commit7771b7c6214ebd1ccce7057a986b38ea81ffaa0e (patch)
tree80fe69606a4a92eb6470295df693a58d085bf7f0
parent281d6d77450a06d68951fed92c5bcb1f83b4c4bc (diff)
downloadbcm5719-llvm-7771b7c6214ebd1ccce7057a986b38ea81ffaa0e.tar.gz
bcm5719-llvm-7771b7c6214ebd1ccce7057a986b38ea81ffaa0e.zip
If a instruction belongs to another function (and not current function) as per debug info attached with the instruction then ignore the dangling lexical scope of this instruction. Such scopes are unreachable.
llvm-svn: 93967
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp16
-rw-r--r--llvm/test/DebugInfo/2010-01-19-DbgScope.ll28
2 files changed, 40 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b9910c35bad..ccadac0cd8e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2042,10 +2042,18 @@ bool DwarfDebug::extractScopeInformation(MachineFunction *MF) {
// Each scope has first instruction and last instruction to mark beginning
// and end of a scope respectively. Create an inverse map that list scopes
// starts (and ends) with an instruction. One instruction may start (or end)
- // multiple scopes.
- for (DenseMap<MDNode *, DbgScope *>::iterator DI = DbgScopeMap.begin(),
- DE = DbgScopeMap.end(); DI != DE; ++DI) {
- DbgScope *S = DI->second;
+ // multiple scopes. Ignore scopes that are not reachable.
+ SmallVector<DbgScope *, 4> WorkList;
+ WorkList.push_back(CurrentFnDbgScope);
+ while (!WorkList.empty()) {
+ DbgScope *S = WorkList.back(); WorkList.pop_back();
+
+ SmallVector<DbgScope *, 4> &Children = S->getScopes();
+ if (!Children.empty())
+ for (SmallVector<DbgScope *, 4>::iterator SI = Children.begin(),
+ SE = Children.end(); SI != SE; ++SI)
+ WorkList.push_back(*SI);
+
if (S->isAbstractScope())
continue;
const MachineInstr *MI = S->getFirstInsn();
diff --git a/llvm/test/DebugInfo/2010-01-19-DbgScope.ll b/llvm/test/DebugInfo/2010-01-19-DbgScope.ll
new file mode 100644
index 00000000000..7afb5a500fb
--- /dev/null
+++ b/llvm/test/DebugInfo/2010-01-19-DbgScope.ll
@@ -0,0 +1,28 @@
+; RUN: llc -O0 < %s -o /dev/null
+; Ignore unreachable scopes.
+declare void @foo(i32) noreturn
+
+define i32 @bar() nounwind ssp {
+entry:
+ br i1 undef, label %bb, label %bb11, !dbg !0
+
+bb: ; preds = %entry
+ call void @foo(i32 0) noreturn nounwind, !dbg !7
+ unreachable, !dbg !7
+
+bb11: ; preds = %entry
+ ret i32 1, !dbg !11
+}
+
+!0 = metadata !{i32 8647, i32 0, metadata !1, null}
+!1 = metadata !{i32 458763, metadata !2} ; [ DW_TAG_lexical_block ]
+!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !"bar", metadata !"bar", metadata !"bar", metadata !3, i32 8639, metadata !4, i1 true, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ]
+!3 = metadata !{i32 458769, i32 0, i32 1, metadata !"c-parser.c", metadata !"llvmgcc", metadata !"LLVM build 00", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
+!4 = metadata !{i32 458773, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !5, i32 0} ; [ DW_TAG_subroutine_type ]
+!5 = metadata !{metadata !6}
+!6 = metadata !{i32 458788, metadata !3, metadata !"char", metadata !3, i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
+!7 = metadata !{i32 8648, i32 0, metadata !8, null}
+!8 = metadata !{i32 458763, metadata !9} ; [ DW_TAG_lexical_block ]
+!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ]
+!10 = metadata !{i32 458798, i32 0, metadata !3, metadata !"bar2", metadata !"bar2", metadata !"bar2", metadata !3, i32 8639, metadata !4, i1 true, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ]
+!11 = metadata !{i32 8652, i32 0, metadata !1, null}
OpenPOWER on IntegriCloud