blob: 90dc0026935c989d8b6fd3102f410faa94176896 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; When constant propogating terminator instructions, the basic block iterator
2; was not updated to refer to the final position of the new terminator. This
3; can be bad, f.e. because constproping a terminator can lead to the
4; destruction of PHI nodes, which invalidates the iterator!
5;
6; Fixed by adding new arguments to ConstantFoldTerminator
7;
Tanya Lattner366c2032008-02-19 01:44:26 +00008; RUN: llvm-as < %s | opt -constprop
Dan Gohmanf17a25c2007-07-18 16:29:46 +00009
Tanya Lattner366c2032008-02-19 01:44:26 +000010define void @build_tree(i32 %ml) {
11; <label>:0
12 br label %bb2
Dan Gohmanf17a25c2007-07-18 16:29:46 +000013
Tanya Lattner366c2032008-02-19 01:44:26 +000014bb2: ; preds = %bb2, %0
15 %reg137 = phi i32 [ %reg140, %bb2 ], [ 12, %0 ] ; <i32> [#uses=1]
16 %reg138 = phi i32 [ %reg139, %bb2 ], [ 0, %0 ] ; <i32> [#uses=1]
17 %reg139 = add i32 %reg138, 1 ; <i32> [#uses=1]
18 %reg140 = add i32 %reg137, -1 ; <i32> [#uses=1]
19 br i1 false, label %bb2, label %bb3
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020
Tanya Lattner366c2032008-02-19 01:44:26 +000021bb3: ; preds = %bb2
22 ret void
23}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024