llvm.org GIT mirror llvm / baccd58
Fix a bug in which node A is replaced by node B, but later node A gets back into the DAG again because it was hiding in one of the node maps: make sure that node replacement happens in those maps too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44263 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 12 years ago
2 changed file(s) with 191 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
9191 /// ExpandedNodes - For nodes that need to be expanded this map indicates
9292 /// which operands are the expanded version of the input.
9393 DenseMap > ExpandedNodes;
94
94
95 /// ReplacedNodes - For nodes that have been replaced with another,
96 /// indicates the replacement node to use.
97 DenseMap ReplacedNodes;
98
9599 /// Worklist - This defines a worklist of nodes to process. In order to be
96100 /// pushed onto this worklist, all operands of a node must have already been
97101 /// processed.
111115 void MarkNewNodes(SDNode *N);
112116
113117 void ReplaceLegalValueWith(SDOperand From, SDOperand To);
114
118
119 void RemapNode(SDOperand &N);
120
115121 SDOperand GetPromotedOp(SDOperand Op) {
116 Op = PromotedNodes[Op];
117 assert(Op.Val && "Operand wasn't promoted?");
118 return Op;
119 }
122 SDOperand &PromotedOp = PromotedNodes[Op];
123 RemapNode(PromotedOp);
124 assert(PromotedOp.Val && "Operand wasn't promoted?");
125 return PromotedOp;
126 }
120127 void SetPromotedOp(SDOperand Op, SDOperand Result);
121128
122129 /// GetPromotedZExtOp - Get a promoted operand and zero extend it to the final
396403 // Anything that used the old node should now use the new one. Note that this
397404 // can potentially cause recursive merging.
398405 DAG.ReplaceAllUsesOfValueWith(From, To);
399
406
407 // The old node may still be present in ExpandedNodes or PromotedNodes.
408 // Inform them about the replacement.
409 ReplacedNodes[From] = To;
410
400411 // Since we just made an unstructured update to the DAG, which could wreak
401412 // general havoc on anything that once used N and now uses Res, walk all users
402413 // of the result, updating their flags.
413424 }
414425 }
415426
427 /// RemapNode - If the specified value was already legalized to another value,
428 /// replace it by that value.
429 void DAGTypeLegalizer::RemapNode(SDOperand &N) {
430 DenseMap::iterator I = ReplacedNodes.find(N);
431 if (I != ReplacedNodes.end()) {
432 RemapNode(I->second);
433 N = I->second;
434 }
435 }
436
416437 void DAGTypeLegalizer::SetPromotedOp(SDOperand Op, SDOperand Result) {
417438 if (Result.Val->getNodeId() == NewNode)
418439 MarkNewNodes(Result.Val);
425446 void DAGTypeLegalizer::GetExpandedOp(SDOperand Op, SDOperand &Lo,
426447 SDOperand &Hi) {
427448 std::pair &Entry = ExpandedNodes[Op];
449 RemapNode(Entry.first);
450 RemapNode(Entry.second);
428451 assert(Entry.first.Val && "Operand isn't expanded");
429452 Lo = Entry.first;
430453 Hi = Entry.second;
0 ; RUN: llvm-as < %s | llc -o -
1 ; XFAIL: *
2 ; Un-XFAIL this once LegalizeDAGTypes is turned on.
3
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
5 target triple = "i686-pc-linux-gnu"
6 %struct.RETURN = type { i32, i32 }
7 %struct.ada__finalization__controlled = type { %struct.system__finalization_root__root_controlled }
8 %struct.ada__streams__root_stream_type = type { %struct.ada__tags__dispatch_table* }
9 %struct.ada__strings__unbounded__string_access = type { i8*, %struct.RETURN* }
10 %struct.ada__strings__unbounded__unbounded_string = type { %struct.ada__finalization__controlled, %struct.ada__strings__unbounded__string_access, i32 }
11 %struct.ada__tags__dispatch_table = type { [1 x i32] }
12 %struct.exception = type { i8, i8, i32, i8*, i8*, i32, i8* }
13 %struct.system__finalization_root__root_controlled = type { %struct.ada__streams__root_stream_type, %struct.system__finalization_root__root_controlled*, %struct.system__finalization_root__root_controlled* }
14 %struct.system__standard_library__exception_data = type { i8, i8, i32, i32, %struct.system__standard_library__exception_data*, i32, void ()* }
15 @C.495.7639 = internal constant %struct.RETURN { i32 1, i32 16 } ; <%struct.RETURN*> [#uses=1]
16 @ada__strings__index_error = external global %struct.exception ; <%struct.exception*> [#uses=1]
17 @.str5 = internal constant [16 x i8] c"a-strunb.adb:690" ; <[16 x i8]*> [#uses=1]
18
19 declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
20
21 declare void @ada__strings__unbounded__realloc_for_chunk(%struct.ada__strings__unbounded__unbounded_string*, i32)
22
23 declare void @__gnat_raise_exception(%struct.system__standard_library__exception_data*, i64)
24
25 define void @ada__strings__unbounded__insert__2(%struct.ada__strings__unbounded__unbounded_string* %source, i32 %before, i64 %new_item.0.0) {
26 entry:
27 %tmp24636 = lshr i64 %new_item.0.0, 32 ; [#uses=1]
28 %tmp24637 = trunc i64 %tmp24636 to i32 ; [#uses=1]
29 %tmp24638 = inttoptr i32 %tmp24637 to %struct.RETURN* ; <%struct.RETURN*> [#uses=2]
30 %tmp25 = getelementptr %struct.RETURN* %tmp24638, i32 0, i32 0 ; [#uses=1]
31 %tmp26 = load i32* %tmp25, align 4 ; [#uses=1]
32 %tmp29 = getelementptr %struct.RETURN* %tmp24638, i32 0, i32 1 ; [#uses=1]
33 %tmp30 = load i32* %tmp29, align 4 ; [#uses=1]
34 %tmp63 = getelementptr %struct.ada__strings__unbounded__unbounded_string* %source, i32 0, i32 1, i32 1 ; <%struct.RETURN**> [#uses=5]
35 %tmp64 = load %struct.RETURN** %tmp63, align 4 ; <%struct.RETURN*> [#uses=1]
36 %tmp65 = getelementptr %struct.RETURN* %tmp64, i32 0, i32 0 ; [#uses=1]
37 %tmp66 = load i32* %tmp65, align 4 ; [#uses=1]
38 %tmp67 = icmp sgt i32 %tmp66, %before ; [#uses=1]
39 br i1 %tmp67, label %bb77, label %bb
40
41 bb: ; preds = %entry
42 %tmp71 = getelementptr %struct.ada__strings__unbounded__unbounded_string* %source, i32 0, i32 2 ; [#uses=4]
43 %tmp72 = load i32* %tmp71, align 4 ; [#uses=1]
44 %tmp73 = add i32 %tmp72, 1 ; [#uses=1]
45 %tmp74 = icmp slt i32 %tmp73, %before ; [#uses=1]
46 br i1 %tmp74, label %bb77, label %bb84
47
48 bb77: ; preds = %bb, %entry
49 tail call void @__gnat_raise_exception( %struct.system__standard_library__exception_data* bitcast (%struct.exception* @ada__strings__index_error to %struct.system__standard_library__exception_data*), i64 or (i64 zext (i32 ptrtoint ([16 x i8]* @.str5 to i32) to i64), i64 shl (i64 zext (i32 ptrtoint (%struct.RETURN* @C.495.7639 to i32) to i64), i64 32)) )
50 unreachable
51
52 bb84: ; preds = %bb
53 %tmp93 = sub i32 %tmp30, %tmp26 ; [#uses=2]
54 %tmp9394 = sext i32 %tmp93 to i36 ; [#uses=1]
55 %tmp95 = shl i36 %tmp9394, 3 ; [#uses=1]
56 %tmp96 = add i36 %tmp95, 8 ; [#uses=2]
57 %tmp97 = icmp sgt i36 %tmp96, -1 ; [#uses=1]
58 %tmp100 = select i1 %tmp97, i36 %tmp96, i36 0 ; [#uses=2]
59 %tmp101 = icmp slt i36 %tmp100, 17179869177 ; [#uses=1]
60 %tmp100.cast = trunc i36 %tmp100 to i32 ; [#uses=1]
61 %min102 = select i1 %tmp101, i32 %tmp100.cast, i32 -8 ; [#uses=1]
62 tail call void @ada__strings__unbounded__realloc_for_chunk( %struct.ada__strings__unbounded__unbounded_string* %source, i32 %min102 )
63 %tmp148 = load i32* %tmp71, align 4 ; [#uses=4]
64 %tmp152 = add i32 %tmp93, 1 ; [#uses=2]
65 %tmp153 = icmp sgt i32 %tmp152, -1 ; [#uses=1]
66 %max154 = select i1 %tmp153, i32 %tmp152, i32 0 ; [#uses=5]
67 %tmp155 = add i32 %tmp148, %max154 ; [#uses=5]
68 %tmp315 = getelementptr %struct.ada__strings__unbounded__unbounded_string* %source, i32 0, i32 1, i32 0 ; [#uses=4]
69 %tmp328 = load %struct.RETURN** %tmp63, align 4 ; <%struct.RETURN*> [#uses=1]
70 %tmp329 = getelementptr %struct.RETURN* %tmp328, i32 0, i32 0 ; [#uses=1]
71 %tmp330 = load i32* %tmp329, align 4 ; [#uses=4]
72 %tmp324 = add i32 %max154, %before ; [#uses=3]
73 %tmp331 = sub i32 %tmp324, %tmp330 ; [#uses=1]
74 %tmp349 = sub i32 %before, %tmp330 ; [#uses=1]
75 %tmp356 = icmp sgt i32 %tmp331, %tmp349 ; [#uses=1]
76 %tmp431 = icmp sgt i32 %tmp324, %tmp155 ; [#uses=2]
77 br i1 %tmp356, label %bb420, label %bb359
78
79 bb359: ; preds = %bb84
80 br i1 %tmp431, label %bb481, label %bb382
81
82 bb382: ; preds = %bb382, %bb359
83 %indvar = phi i32 [ 0, %bb359 ], [ %indvar.next, %bb382 ] ; [#uses=2]
84 %max379.pn = phi i32 [ %max154, %bb359 ], [ %L492b.0, %bb382 ] ; [#uses=1]
85 %before.pn = phi i32 [ %before, %bb359 ], [ 1, %bb382 ] ; [#uses=1]
86 %L492b.0 = add i32 %before.pn, %max379.pn ; [#uses=3]
87 %tmp386 = load %struct.RETURN** %tmp63, align 4 ; <%struct.RETURN*> [#uses=1]
88 %tmp387 = getelementptr %struct.RETURN* %tmp386, i32 0, i32 0 ; [#uses=1]
89 %tmp388 = load i32* %tmp387, align 4 ; [#uses=2]
90 %tmp392 = load i8** %tmp315, align 4 ; [#uses=2]
91 %R493b.0 = add i32 %indvar, %before ; [#uses=1]
92 %tmp405 = sub i32 %R493b.0, %tmp388 ; [#uses=1]
93 %tmp406 = getelementptr i8* %tmp392, i32 %tmp405 ; [#uses=1]
94 %tmp407 = load i8* %tmp406, align 1 ; [#uses=1]
95 %tmp408 = sub i32 %L492b.0, %tmp388 ; [#uses=1]
96 %tmp409 = getelementptr i8* %tmp392, i32 %tmp408 ; [#uses=1]
97 store i8 %tmp407, i8* %tmp409, align 1
98 %tmp414 = icmp eq i32 %L492b.0, %tmp155 ; [#uses=1]
99 %indvar.next = add i32 %indvar, 1 ; [#uses=1]
100 br i1 %tmp414, label %bb481, label %bb382
101
102 bb420: ; preds = %bb84
103 br i1 %tmp431, label %bb481, label %bb436.preheader
104
105 bb436.preheader: ; preds = %bb420
106 %tmp4468 = load i8** %tmp315, align 4 ; [#uses=2]
107 %tmp4599 = sub i32 %tmp148, %tmp330 ; [#uses=1]
108 %tmp46010 = getelementptr i8* %tmp4468, i32 %tmp4599 ; [#uses=1]
109 %tmp46111 = load i8* %tmp46010, align 1 ; [#uses=1]
110 %tmp46212 = sub i32 %tmp155, %tmp330 ; [#uses=1]
111 %tmp46313 = getelementptr i8* %tmp4468, i32 %tmp46212 ; [#uses=1]
112 store i8 %tmp46111, i8* %tmp46313, align 1
113 %exitcond14 = icmp eq i32 %tmp155, %tmp324 ; [#uses=1]
114 br i1 %exitcond14, label %bb481, label %bb.nph
115
116 bb.nph: ; preds = %bb436.preheader
117 %tmp5 = sub i32 %tmp148, %before ; [#uses=1]
118 br label %bb478
119
120 bb478: ; preds = %bb478, %bb.nph
121 %indvar6422 = phi i32 [ 0, %bb.nph ], [ %indvar.next643, %bb478 ] ; [#uses=1]
122 %indvar.next643 = add i32 %indvar6422, 1 ; [#uses=4]
123 %L490b.0 = sub i32 %tmp155, %indvar.next643 ; [#uses=1]
124 %R491b.0 = sub i32 %tmp148, %indvar.next643 ; [#uses=1]
125 %tmp440 = load %struct.RETURN** %tmp63, align 4 ; <%struct.RETURN*> [#uses=1]
126 %tmp441 = getelementptr %struct.RETURN* %tmp440, i32 0, i32 0 ; [#uses=1]
127 %tmp442 = load i32* %tmp441, align 4 ; [#uses=2]
128 %tmp446 = load i8** %tmp315, align 4 ; [#uses=2]
129 %tmp459 = sub i32 %R491b.0, %tmp442 ; [#uses=1]
130 %tmp460 = getelementptr i8* %tmp446, i32 %tmp459 ; [#uses=1]
131 %tmp461 = load i8* %tmp460, align 1 ; [#uses=1]
132 %tmp462 = sub i32 %L490b.0, %tmp442 ; [#uses=1]
133 %tmp463 = getelementptr i8* %tmp446, i32 %tmp462 ; [#uses=1]
134 store i8 %tmp461, i8* %tmp463, align 1
135 %exitcond = icmp eq i32 %indvar.next643, %tmp5 ; [#uses=1]
136 br i1 %exitcond, label %bb481, label %bb478
137
138 bb481: ; preds = %bb478, %bb436.preheader, %bb420, %bb382, %bb359
139 %tmp577 = add i32 %before, -1 ; [#uses=3]
140 %tmp578 = add i32 %max154, %tmp577 ; [#uses=2]
141 %tmp581 = icmp sge i32 %tmp578, %tmp577 ; [#uses=1]
142 %max582 = select i1 %tmp581, i32 %tmp578, i32 %tmp577 ; [#uses=1]
143 %tmp584 = sub i32 %max582, %before ; [#uses=1]
144 %tmp585 = add i32 %tmp584, 1 ; [#uses=2]
145 %tmp586 = icmp sgt i32 %tmp585, -1 ; [#uses=1]
146 %max587 = select i1 %tmp586, i32 %tmp585, i32 0 ; [#uses=1]
147 %tmp591 = load %struct.RETURN** %tmp63, align 4 ; <%struct.RETURN*> [#uses=1]
148 %tmp592 = getelementptr %struct.RETURN* %tmp591, i32 0, i32 0 ; [#uses=1]
149 %tmp593 = load i32* %tmp592, align 4 ; [#uses=1]
150 %tmp597 = load i8** %tmp315, align 4 ; [#uses=1]
151 %tmp600621 = trunc i64 %new_item.0.0 to i32 ; [#uses=1]
152 %tmp600622 = inttoptr i32 %tmp600621 to i8* ; [#uses=1]
153 %tmp601 = sub i32 %before, %tmp593 ; [#uses=1]
154 %tmp602 = getelementptr i8* %tmp597, i32 %tmp601 ; [#uses=1]
155 tail call void @llvm.memcpy.i32( i8* %tmp602, i8* %tmp600622, i32 %max587, i32 1 )
156 %tmp606 = load i32* %tmp71, align 4 ; [#uses=1]
157 %tmp613 = add i32 %tmp606, %max154 ; [#uses=1]
158 store i32 %tmp613, i32* %tmp71, align 4
159 ret void
160 }