llvm.org GIT mirror llvm / 1d68d21
Add variables into a scope before constructing scope DIE otherwise variables won't be included DIE tree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107228 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 10 years ago
2 changed file(s) with 54 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
27452745 // Construct abstract scopes.
27462746 for (SmallVector::iterator AI = AbstractScopesList.begin(),
27472747 AE = AbstractScopesList.end(); AI != AE; ++AI) {
2748 constructScopeDIE(*AI);
27492748 DISubprogram SP((*AI)->getScopeNode());
27502749 if (SP.Verify()) {
27512750 // Collect info for variables that were optimized out.
27602759 DIVariable DV(cast_or_null(NMD->getOperand(i)));
27612760 if (!DV || !ProcessedVars.insert(DV))
27622761 continue;
2763 DbgScope *Scope = DbgScopeMap.lookup(DV.getContext());
2762 DbgScope *Scope = AbstractScopes.lookup(DV.getContext());
27642763 if (Scope)
27652764 Scope->addVariable(new DbgVariable(DV));
27662765 }
27672766 }
27682767 }
2768 constructScopeDIE(*AI);
27692769 }
27702770
27712771 DIE *CurFnDIE = constructScopeDIE(CurrentFnDbgScope);
0 ; RUN: llc -O2 %s -o - | FileCheck %s
1 ; Check struct X for dead variable xyz from inlined function foo.
2
3 ; CHECK: DW_TAG_structure_type
4 ; CHECK-NEXT: DW_AT_sibling
5 ; CHECK-NEXT: DW_AT_name
6
7
8 @i = common global i32 0 ; [#uses=2]
9
10 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
11
12 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
13
14 define i32 @bar() nounwind ssp {
15 entry:
16 %0 = load i32* @i, align 4, !dbg !17 ; [#uses=2]
17 tail call void @llvm.dbg.value(metadata !{i32 %0}, i64 0, metadata !9), !dbg !19
18 tail call void @llvm.dbg.declare(metadata !20, metadata !10), !dbg !21
19 %1 = mul nsw i32 %0, %0, !dbg !22 ; [#uses=2]
20 store i32 %1, i32* @i, align 4, !dbg !17
21 ret i32 %1, !dbg !23
22 }
23
24 !llvm.dbg.sp = !{!0, !6}
25 !llvm.dbg.lv.foo = !{!9, !10}
26 !llvm.dbg.gv = !{!16}
27
28 !0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"", metadata !1, i32 9, metadata !3, i1 true, i1 true, i32 0, i32 0, null, i1 false, i1 true, null} ; [ DW_TAG_subprogram ]
29 !1 = metadata !{i32 524329, metadata !"bar.c", metadata !"/tmp/", metadata !2} ; [ DW_TAG_file_type ]
30 !2 = metadata !{i32 524305, i32 0, i32 1, metadata !"bar.c", metadata !"/tmp/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
31 !3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
32 !4 = metadata !{metadata !5, metadata !5}
33 !5 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
34 !6 = metadata !{i32 524334, i32 0, metadata !1, metadata !"bar", metadata !"bar", metadata !"bar", metadata !1, i32 14, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true, i32 ()* @bar} ; [ DW_TAG_subprogram ]
35 !7 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null} ; [ DW_TAG_subroutine_type ]
36 !8 = metadata !{metadata !5}
37 !9 = metadata !{i32 524545, metadata !0, metadata !"j", metadata !1, i32 9, metadata !5} ; [ DW_TAG_arg_variable ]
38 !10 = metadata !{i32 524544, metadata !11, metadata !"xyz", metadata !1, i32 10, metadata !12} ; [ DW_TAG_auto_variable ]
39 !11 = metadata !{i32 524299, metadata !0, i32 9, i32 0} ; [ DW_TAG_lexical_block ]
40 !12 = metadata !{i32 524307, metadata !0, metadata !"X", metadata !1, i32 10, i64 64, i64 32, i64 0, i32 0, null, metadata !13, i32 0, null} ; [ DW_TAG_structure_type ]
41 !13 = metadata !{metadata !14, metadata !15}
42 !14 = metadata !{i32 524301, metadata !12, metadata !"a", metadata !1, i32 10, i64 32, i64 32, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ]
43 !15 = metadata !{i32 524301, metadata !12, metadata !"b", metadata !1, i32 10, i64 32, i64 32, i64 32, i32 0, metadata !5} ; [ DW_TAG_member ]
44 !16 = metadata !{i32 524340, i32 0, metadata !1, metadata !"i", metadata !"i", metadata !"", metadata !1, i32 5, metadata !5, i1 false, i1 true, i32* @i} ; [ DW_TAG_variable ]
45 !17 = metadata !{i32 15, i32 0, metadata !18, null}
46 !18 = metadata !{i32 524299, metadata !6, i32 14, i32 0} ; [ DW_TAG_lexical_block ]
47 !19 = metadata !{i32 9, i32 0, metadata !0, metadata !17}
48 !20 = metadata !{null}
49 !21 = metadata !{i32 9, i32 0, metadata !11, metadata !17}
50 !22 = metadata !{i32 11, i32 0, metadata !11, metadata !17}
51 !23 = metadata !{i32 16, i32 0, metadata !18, null}