Fix for pr24866
[oota-llvm.git] / test / Analysis / ValueTracking / pr24866.ll
1 ; RUN: opt -S %s -value-tracking-dom-conditions -licm -load-combine | FileCheck %s
2 ; In pr24866.ll, we saw a crash when accessing a nullptr returned when
3 ; asking for a dominator tree Node.  This reproducer is really fragile,
4 ; but it's currently the best we have.
5
6 %struct.c_derived_tbl.2.5.8.11.14.17.23.38.59.80.92.98.104.107.155.183 = type { [256 x i32], [256 x i8] }
7
8
9 ; Function Attrs: nounwind uwtable
10 define void @encode_one_blockX2(%struct.c_derived_tbl.2.5.8.11.14.17.23.38.59.80.92.98.104.107.155.183* nocapture readonly %actbl) #0 {
11 ; CHECK-LABEL: @encode_one_blockX2
12 entry:
13   br i1 false, label %L_KLOOP_01, label %L_KLOOP.preheader
14
15 L_KLOOP_01:                                       ; preds = %while.end, %entry
16   br label %L_KLOOP.preheader
17
18 L_KLOOP_08:                                       ; preds = %while.end
19   br label %L_KLOOP.preheader
20
21 L_KLOOP.preheader:                                ; preds = %L_KLOOP_08, %L_KLOOP_01, %entry
22   %r.2.ph = phi i32 [ undef, %L_KLOOP_08 ], [ 0, %entry ], [ undef, %L_KLOOP_01 ]
23   br label %L_KLOOP
24
25 L_KLOOP:                                          ; preds = %while.end, %L_KLOOP.preheader
26   %r.2 = phi i32 [ 0, %while.end ], [ %r.2.ph, %L_KLOOP.preheader ]
27   br i1 true, label %while.body, label %while.end
28
29 while.body:                                       ; preds = %while.body, %L_KLOOP
30   br label %while.body
31
32 while.end:                                        ; preds = %L_KLOOP
33   %shl105 = shl i32 %r.2, 4
34   %add106 = add nsw i32 %shl105, undef
35   %idxprom107 = sext i32 %add106 to i64
36   %arrayidx108 = getelementptr inbounds %struct.c_derived_tbl.2.5.8.11.14.17.23.38.59.80.92.98.104.107.155.183, %struct.c_derived_tbl.2.5.8.11.14.17.23.38.59.80.92.98.104.107.155.183* %actbl, i64 0, i32 0, i64 %idxprom107
37   %0 = load i32, i32* %arrayidx108, align 4
38   %arrayidx110 = getelementptr inbounds %struct.c_derived_tbl.2.5.8.11.14.17.23.38.59.80.92.98.104.107.155.183, %struct.c_derived_tbl.2.5.8.11.14.17.23.38.59.80.92.98.104.107.155.183* %actbl, i64 0, i32 1, i64 %idxprom107
39   %1 = load i8, i8* %arrayidx110, align 1
40   indirectbr i8* undef, [label %L_KLOOP_DONE, label %L_KLOOP_01, label %L_KLOOP_08, label %L_KLOOP]
41
42 L_KLOOP_DONE:                                     ; preds = %while.end
43   ret void
44 }