llvm.org GIT mirror llvm / 9126c0d
Keep track of incoming debug value of unused argument. Radar 7927666. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105285 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 10 years ago
3 changed file(s) with 72 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
697697 /// consumed.
698698 void SelectionDAGBuilder::clear() {
699699 NodeMap.clear();
700 UnusedArgNodeMap.clear();
700701 PendingLoads.clear();
701702 PendingExports.clear();
702703 CurDebugLoc = DebugLoc();
40624063 } else {
40634064 bool createUndef = false;
40644065 // FIXME : Why not use getValue() directly ?
4065 SDValue &N = NodeMap[V];
4066 SDValue N = NodeMap[V];
4067 if (!N.getNode() && isa(V))
4068 // Check unused arguments map.
4069 N = UnusedArgNodeMap[V];
40664070 if (N.getNode()) {
40674071 if (!EmitFuncArgumentDbgValue(DI, V, Variable, Offset, N)) {
40684072 SDV = DAG.getDbgValue(Variable, N.getNode(),
60316035 SmallVector ValueVTs;
60326036 ComputeValueVTs(TLI, I->getType(), ValueVTs);
60336037 unsigned NumValues = ValueVTs.size();
6038
6039 // If this argument is unused then remember its value. It is used to generate
6040 // debugging information.
6041 if (I->use_empty() && NumValues)
6042 SDB->setUnusedArgValue(I, InVals[i]);
6043
60346044 for (unsigned Value = 0; Value != NumValues; ++Value) {
60356045 EVT VT = ValueVTs[Value];
60366046 EVT PartVT = TLI.getRegisterType(*CurDAG->getContext(), VT);
8787 DebugLoc CurDebugLoc;
8888
8989 DenseMap NodeMap;
90
91 /// UnusedArgNodeMap - Maps argument value for unused arguments. This is used
92 /// to preserve debug information for incoming arguments.
93 DenseMap UnusedArgNodeMap;
9094
9195 public:
9296 /// PendingLoads - Loads are not emitted to the program immediately. We bunch
344348
345349 void setValue(const Value *V, SDValue NewN) {
346350 SDValue &N = NodeMap[V];
351 assert(N.getNode() == 0 && "Already set a value for this node!");
352 N = NewN;
353 }
354
355 void setUnusedArgValue(const Value *V, SDValue NewN) {
356 SDValue &N = UnusedArgNodeMap[V];
347357 assert(N.getNode() == 0 && "Already set a value for this node!");
348358 N = NewN;
349359 }
0 ; RUN: llc -O2 < %s | grep this | grep -v undef
1 ; Test to check that unused argument 'this' is not undefined in debug info.
2
3 %struct.foo = type { i32 }
4
5 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.foo*, i32)* @_ZN3foo3bazEi to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
6
7 define i32 @_ZN3foo3bazEi(%struct.foo* nocapture %this, i32 %x) nounwind readnone optsize noinline ssp align 2 {
8 entry:
9 tail call void @llvm.dbg.value(metadata !{%struct.foo* %this}, i64 0, metadata !15)
10 tail call void @llvm.dbg.value(metadata !{i32 %x}, i64 0, metadata !16)
11 %0 = mul nsw i32 %x, 7, !dbg !29 ; [#uses=1]
12 %1 = add nsw i32 %0, 1, !dbg !29 ; [#uses=1]
13 ret i32 %1, !dbg !29
14 }
15
16 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
17
18 !llvm.dbg.lv = !{!0, !14, !15, !16, !17, !24, !25, !28}
19
20 !0 = metadata !{i32 524545, metadata !1, metadata !"this", metadata !3, i32 11, metadata !12} ; [ DW_TAG_arg_variable ]
21 !1 = metadata !{i32 524334, i32 0, metadata !2, metadata !"bar", metadata !"bar", metadata !"_ZN3foo3barEi", metadata !3, i32 11, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
22 !2 = metadata !{i32 524307, metadata !3, metadata !"foo", metadata !3, i32 3, i64 32, i64 32, i64 0, i32 0, null, metadata !5, i32 0, null} ; [ DW_TAG_structure_type ]
23 !3 = metadata !{i32 524329, metadata !"foo.cp", metadata !"/tmp/", metadata !4} ; [ DW_TAG_file_type ]
24 !4 = metadata !{i32 524305, i32 0, i32 4, metadata !"foo.cp", metadata !"/tmp/", metadata !"4.2.1 LLVM build", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
25 !5 = metadata !{metadata !6, metadata !1, metadata !8}
26 !6 = metadata !{i32 524301, metadata !2, metadata !"y", metadata !3, i32 8, i64 32, i64 32, i64 0, i32 0, metadata !7} ; [ DW_TAG_member ]
27 !7 = metadata !{i32 524324, metadata !3, metadata !"int", metadata !3, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
28 !8 = metadata !{i32 524334, i32 0, metadata !2, metadata !"baz", metadata !"baz", metadata !"_ZN3foo3bazEi", metadata !3, i32 15, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
29 !9 = metadata !{i32 524309, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, null} ; [ DW_TAG_subroutine_type ]
30 !10 = metadata !{metadata !7, metadata !11, metadata !7}
31 !11 = metadata !{i32 524303, metadata !3, metadata !"", metadata !3, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !2} ; [ DW_TAG_pointer_type ]
32 !12 = metadata !{i32 524326, metadata !3, metadata !"", metadata !3, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !13} ; [ DW_TAG_const_type ]
33 !13 = metadata !{i32 524303, metadata !3, metadata !"", metadata !3, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_pointer_type ]
34 !14 = metadata !{i32 524545, metadata !1, metadata !"x", metadata !3, i32 11, metadata !7} ; [ DW_TAG_arg_variable ]
35 !15 = metadata !{i32 524545, metadata !8, metadata !"this", metadata !3, i32 15, metadata !12} ; [ DW_TAG_arg_variable ]
36 !16 = metadata !{i32 524545, metadata !8, metadata !"x", metadata !3, i32 15, metadata !7} ; [ DW_TAG_arg_variable ]
37 !17 = metadata !{i32 524545, metadata !18, metadata !"argc", metadata !3, i32 19, metadata !7} ; [ DW_TAG_arg_variable ]
38 !18 = metadata !{i32 524334, i32 0, metadata !3, metadata !"main", metadata !"main", metadata !"main", metadata !3, i32 19, metadata !19, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
39 !19 = metadata !{i32 524309, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !20, i32 0, null} ; [ DW_TAG_subroutine_type ]
40 !20 = metadata !{metadata !7, metadata !7, metadata !21}
41 !21 = metadata !{i32 524303, metadata !3, metadata !"", metadata !3, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !22} ; [ DW_TAG_pointer_type ]
42 !22 = metadata !{i32 524303, metadata !3, metadata !"", metadata !3, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !23} ; [ DW_TAG_pointer_type ]
43 !23 = metadata !{i32 524324, metadata !3, metadata !"char", metadata !3, i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
44 !24 = metadata !{i32 524545, metadata !18, metadata !"argv", metadata !3, i32 19, metadata !21} ; [ DW_TAG_arg_variable ]
45 !25 = metadata !{i32 524544, metadata !26, metadata !"a", metadata !3, i32 20, metadata !2} ; [ DW_TAG_auto_variable ]
46 !26 = metadata !{i32 524299, metadata !27, i32 19, i32 0} ; [ DW_TAG_lexical_block ]
47 !27 = metadata !{i32 524299, metadata !18, i32 19, i32 0} ; [ DW_TAG_lexical_block ]
48 !28 = metadata !{i32 524544, metadata !26, metadata !"b", metadata !3, i32 21, metadata !7} ; [ DW_TAG_auto_variable ]
49 !29 = metadata !{i32 16, i32 0, metadata !30, null}
50 !30 = metadata !{i32 524299, metadata !8, i32 15, i32 0} ; [ DW_TAG_lexical_block ]