xref: /aosp_15_r20/external/llvm/test/Other/2002-03-11-ConstPropCrash.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; When constant propogating terminator instructions, the basic block iterator
2*9880d681SAndroid Build Coastguard Worker; was not updated to refer to the final position of the new terminator.  This
3*9880d681SAndroid Build Coastguard Worker; can be bad, f.e. because constproping a terminator can lead to the
4*9880d681SAndroid Build Coastguard Worker; destruction of PHI nodes, which invalidates the iterator!
5*9880d681SAndroid Build Coastguard Worker;
6*9880d681SAndroid Build Coastguard Worker; Fixed by adding new arguments to ConstantFoldTerminator
7*9880d681SAndroid Build Coastguard Worker;
8*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -constprop
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine void @build_tree(i32 %ml) {
11*9880d681SAndroid Build Coastguard Worker; <label>:0
12*9880d681SAndroid Build Coastguard Worker        br label %bb2
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerbb2:            ; preds = %bb2, %0
15*9880d681SAndroid Build Coastguard Worker        %reg137 = phi i32 [ %reg140, %bb2 ], [ 12, %0 ]         ; <i32> [#uses=1]
16*9880d681SAndroid Build Coastguard Worker        %reg138 = phi i32 [ %reg139, %bb2 ], [ 0, %0 ]          ; <i32> [#uses=1]
17*9880d681SAndroid Build Coastguard Worker        %reg139 = add i32 %reg138, 1            ; <i32> [#uses=1]
18*9880d681SAndroid Build Coastguard Worker        %reg140 = add i32 %reg137, -1           ; <i32> [#uses=1]
19*9880d681SAndroid Build Coastguard Worker        br i1 false, label %bb2, label %bb3
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerbb3:            ; preds = %bb2
22*9880d681SAndroid Build Coastguard Worker        ret void
23*9880d681SAndroid Build Coastguard Worker}
24*9880d681SAndroid Build Coastguard Worker
25