• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc %s -o - | FileCheck %s
2; This file checks some weird corner case in LiveRangeEdit.
3; We used to do crash when we eliminate the definition
4; of the product of splitting when the original live-range
5; has already been removed.
6; Basically, we have the following input.
7; v1 = loadimm cst
8; ...
9; = use v1
10;
11; We split the live-range like this:
12; v1 = loadimm cst
13; ...
14; v2 = copy v1
15; ...
16; = use v2
17;
18; We actually issue loadimm instead of the copy:
19; v1 = loadimm cst
20; ...
21; v2 = loadimm cst
22; ...
23; = use v2
24;
25; v1 is now dead so we remove its live-range.
26; Actually, we shrink it to empty to keep the
27; instruction around for futher remat opportunities
28; (accessbile via the origin pointer.)
29;
30; Later v2 gets remove as well (e.g., because we
31; remat it closer to its use) and the live-range
32; gets eliminated. We used to crash at this point
33; because we were looking for a VNI of origin (v1)
34; at the slot index of the definition of v2. However,
35; we do not have a VNI for v1 at this point, since the
36; live-range is now empty... crash!
37; PR27983
38
39source_filename = "bugpoint-output-1e29d28.bc"
40target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
41target triple = "i386-unknown-linux-gnu"
42
43@r = external global i32, align 4
44@k = external global i32, align 4
45@g = external global i32, align 4
46@a = external global i16, align 2
47@p = external global i32, align 4
48@n = external global i16, align 2
49@.str = external unnamed_addr constant [12 x i8], align 1
50@.str.1 = external unnamed_addr constant [13 x i8], align 1
51@s = external global i32, align 4
52@z = external global i16, align 2
53
54; CHECK-LABEL: fn1:
55define void @fn1() #0 {
56entry:
57  br label %for.cond
58
59for.cond:                                         ; preds = %cleanup100, %for.end29, %entry
60  %t7.0 = phi i16 [ undef, %entry ], [ %t7.1, %for.end29 ], [ %t7.19, %cleanup100 ]
61  %t9.0 = phi i32 [ undef, %entry ], [ %t9.1, %for.end29 ], [ 0, %cleanup100 ]
62  %t2.0 = phi i32 [ undef, %entry ], [ undef, %for.end29 ], [ %t2.18, %cleanup100 ]
63  %tmp = load i32, i32* @r, align 4
64  br i1 undef, label %if.then, label %if.end7
65
66if.then:                                          ; preds = %for.cond
67  %tobool = icmp ne i32 %tmp, 0
68  %tobool1 = icmp ne i32 %t2.0, 0
69  %tmp1 = and i1 %tobool1, %tobool
70  %land.ext = zext i1 %tmp1 to i32
71  %tmp2 = load i32, i32* @k, align 4
72  %shr = lshr i32 %land.ext, %tmp2
73  %tobool4 = icmp ne i32 %shr, 0
74  %or.cond = and i1 false, %tobool4
75  br i1 %or.cond, label %L6, label %if.end7
76
77if.end7:                                          ; preds = %if.then, %for.cond
78  %t2.1 = phi i32 [ %shr, %if.then ], [ %t2.0, %for.cond ]
79  %tobool8 = icmp eq i32 undef, 0
80  br i1 %tobool8, label %if.end11, label %for.cond10
81
82for.cond10:                                       ; preds = %for.cond10, %if.end7
83  br label %for.cond10
84
85if.end11:                                         ; preds = %if.end7
86  %tmp3 = load i32, i32* @g, align 4
87  %tmp4 = load i16, i16* @a, align 2
88  %conv = sext i16 %tmp4 to i32
89  %div = sdiv i32 %tmp3, %conv
90  %tobool12 = icmp eq i32 %div, 0
91  br i1 %tobool12, label %for.cond15, label %L5
92
93for.cond15:                                       ; preds = %for.cond17, %if.end11
94  %t7.1 = phi i16 [ %t7.2, %for.cond17 ], [ %t7.0, %if.end11 ]
95  %t9.1 = phi i32 [ %t9.2, %for.cond17 ], [ %t9.0, %if.end11 ]
96  %tobool16 = icmp eq i32 undef, 0
97  br i1 %tobool16, label %for.end29, label %for.cond17
98
99for.cond17:                                       ; preds = %for.cond20, %for.cond15
100  %t7.2 = phi i16 [ %t7.3, %for.cond20 ], [ %t7.1, %for.cond15 ]
101  %t9.2 = phi i32 [ undef, %for.cond20 ], [ %t9.1, %for.cond15 ]
102  %tobool18 = icmp eq i8 undef, 0
103  br i1 %tobool18, label %for.cond15, label %for.cond20
104
105for.cond20:                                       ; preds = %for.cond23, %for.cond17
106  %t7.3 = phi i16 [ %t7.4, %for.cond23 ], [ %t7.2, %for.cond17 ]
107  %tobool21 = icmp eq i32 undef, 0
108  br i1 %tobool21, label %for.cond17, label %for.cond23
109
110for.cond23:                                       ; preds = %L1, %for.cond20
111  %t7.4 = phi i16 [ %t7.5, %L1 ], [ %t7.3, %for.cond20 ]
112  %tobool24 = icmp eq i8 undef, 0
113  br i1 %tobool24, label %for.cond20, label %L1
114
115L1:                                               ; preds = %cleanup100, %for.cond23
116  %t7.5 = phi i16 [ %t7.19, %cleanup100 ], [ %t7.4, %for.cond23 ]
117  %conv26 = sext i16 undef to i64
118  br label %for.cond23
119
120for.end29:                                        ; preds = %for.cond15
121  br i1 undef, label %for.cond, label %for.cond32thread-pre-split
122
123for.cond32thread-pre-split:                       ; preds = %for.end29
124  %.pr = load i32, i32* @p, align 4
125  br label %for.cond32
126
127for.cond32:                                       ; preds = %for.inc94, %for.cond32thread-pre-split
128  %t7.6 = phi i16 [ %t7.1, %for.cond32thread-pre-split ], [ %t7.17, %for.inc94 ]
129  %t3.4 = phi i64 [ 0, %for.cond32thread-pre-split ], [ 0, %for.inc94 ]
130  %t9.6 = phi i32 [ %t9.1, %for.cond32thread-pre-split ], [ 0, %for.inc94 ]
131  %t2.7 = phi i32 [ undef, %for.cond32thread-pre-split ], [ %t2.16, %for.inc94 ]
132  %tobool33 = icmp eq i32 0, 0
133  br i1 %tobool33, label %for.end95, label %for.body34
134
135for.body34:                                       ; preds = %for.cond32
136  %tobool35 = icmp eq i16 undef, 0
137  br i1 %tobool35, label %for.inc94, label %if.then36
138
139if.then36:                                        ; preds = %for.body34
140  %tmp5 = load i16, i16* @n, align 2
141  %tobool37 = icmp eq i32 undef, 0
142  br i1 %tobool37, label %if.end78, label %if.then38
143
144if.then38:                                        ; preds = %if.then36
145  tail call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i64 undef)
146  %tobool40 = icmp eq i32 undef, 0
147  br i1 %tobool40, label %L3, label %cleanup100
148
149L3:                                               ; preds = %while.end.split, %if.then38
150  %t7.7 = phi i16 [ %tmp5, %if.then38 ], [ %t7.15, %while.end.split ]
151  %t3.5 = phi i64 [ %t3.4, %if.then38 ], [ %t3.11, %while.end.split ]
152  %t2.8 = phi i32 [ %t2.7, %if.then38 ], [ %t2.14, %while.end.split ]
153  %tobool43 = icmp eq i32 undef, 0
154  br i1 %tobool43, label %if.end48, label %cleanup75
155
156if.end48:                                         ; preds = %L3
157  tail call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i64 %t3.5)
158  br i1 undef, label %if.end61, label %for.cond52.preheader
159
160for.cond52.preheader:                             ; preds = %if.end48
161  %tobool57 = icmp eq i16 undef, 0
162  %.130 = select i1 %tobool57, i16 -8, i16 0
163  br label %if.end61
164
165if.end61:                                         ; preds = %for.cond52.preheader, %if.end48
166  %t7.9 = phi i16 [ %t7.7, %if.end48 ], [ %.130, %for.cond52.preheader ]
167  %tobool62 = icmp eq i32 undef, 0
168  br i1 %tobool62, label %if.end71, label %if.then63
169
170if.then63:                                        ; preds = %if.end61
171  br i1 undef, label %if.end67, label %L5
172
173L5:                                               ; preds = %cleanup100.L5_crit_edge, %if.then63, %if.end11
174  %.pre = phi i32 [ %.pre.pre, %cleanup100.L5_crit_edge ], [ undef, %if.then63 ], [ %tmp, %if.end11 ]
175  %t7.10 = phi i16 [ %t7.19, %cleanup100.L5_crit_edge ], [ %t7.9, %if.then63 ], [ %t7.0, %if.end11 ]
176  %t3.6 = phi i64 [ 0, %cleanup100.L5_crit_edge ], [ %t3.5, %if.then63 ], [ 2, %if.end11 ]
177  %t9.8 = phi i32 [ 0, %cleanup100.L5_crit_edge ], [ undef, %if.then63 ], [ %t9.0, %if.end11 ]
178  %t2.9 = phi i32 [ %t2.18, %cleanup100.L5_crit_edge ], [ %t2.8, %if.then63 ], [ %t2.1, %if.end11 ]
179  store i32 %t9.8, i32* @s, align 4
180  br label %if.end67
181
182if.end67:                                         ; preds = %L5, %if.then63
183  %tmp6 = phi i32 [ %.pre, %L5 ], [ undef, %if.then63 ]
184  %t7.11 = phi i16 [ %t7.10, %L5 ], [ %t7.9, %if.then63 ]
185  %t3.7 = phi i64 [ %t3.6, %L5 ], [ %t3.5, %if.then63 ]
186  %t9.9 = phi i32 [ %t9.8, %L5 ], [ undef, %if.then63 ]
187  %t2.10 = phi i32 [ %t2.9, %L5 ], [ %t2.8, %if.then63 ]
188  %tobool68 = icmp eq i32 %tmp6, 0
189  br i1 %tobool68, label %if.end71, label %for.end95
190
191if.end71:                                         ; preds = %if.end67, %if.end61
192  %t7.12 = phi i16 [ %t7.11, %if.end67 ], [ %t7.9, %if.end61 ]
193  %t3.8 = phi i64 [ %t3.7, %if.end67 ], [ %t3.5, %if.end61 ]
194  %tobool72 = icmp eq i32 undef, 0
195  br i1 %tobool72, label %cleanup75.thread128, label %if.then73
196
197if.then73:                                        ; preds = %if.end71
198  br label %cleanup100
199
200cleanup75.thread128:                              ; preds = %if.end71
201  br label %if.end78
202
203cleanup75:                                        ; preds = %L3
204  br i1 false, label %for.cond98, label %for.end95
205
206if.end78:                                         ; preds = %cleanup75.thread128, %if.then36
207  %t7.14 = phi i16 [ %tmp5, %if.then36 ], [ 0, %cleanup75.thread128 ]
208  %t3.10 = phi i64 [ %t3.4, %if.then36 ], [ %t3.8, %cleanup75.thread128 ]
209  %t9.12 = phi i32 [ %t9.6, %if.then36 ], [ undef, %cleanup75.thread128 ]
210  %t2.13 = phi i32 [ %t2.7, %if.then36 ], [ undef, %cleanup75.thread128 ]
211  store i16 %t7.14, i16* @z, align 2
212  br label %L6
213
214L6:                                               ; preds = %if.end78, %if.then
215  %t7.15 = phi i16 [ %t7.0, %if.then ], [ %t7.14, %if.end78 ]
216  %t3.11 = phi i64 [ 2, %if.then ], [ %t3.10, %if.end78 ]
217  %t9.13 = phi i32 [ %t9.0, %if.then ], [ %t9.12, %if.end78 ]
218  %t2.14 = phi i32 [ %shr, %if.then ], [ %t2.13, %if.end78 ]
219  br i1 undef, label %while.condthread-pre-split, label %for.inc94
220
221while.condthread-pre-split:                       ; preds = %L6
222  %tobool83 = icmp eq i32 undef, 0
223  br i1 %tobool83, label %while.end.split, label %while.cond
224
225while.cond:                                       ; preds = %while.cond, %while.condthread-pre-split
226  br label %while.cond
227
228while.end.split:                                  ; preds = %while.condthread-pre-split
229  %tobool84 = icmp eq i16 undef, 0
230  br i1 %tobool84, label %for.inc94, label %L3
231
232for.inc94:                                        ; preds = %while.end.split, %L6, %for.body34
233  %t7.17 = phi i16 [ %t7.6, %for.body34 ], [ %t7.15, %L6 ], [ %t7.15, %while.end.split ]
234  %t2.16 = phi i32 [ %t2.7, %for.body34 ], [ %t2.14, %L6 ], [ %t2.14, %while.end.split ]
235  store i32 undef, i32* @p, align 4
236  br label %for.cond32
237
238for.end95:                                        ; preds = %cleanup75, %if.end67, %for.cond32
239  %t7.18 = phi i16 [ %t7.6, %for.cond32 ], [ %t7.7, %cleanup75 ], [ %t7.11, %if.end67 ]
240  %t2.17 = phi i32 [ %t2.7, %for.cond32 ], [ %t2.8, %cleanup75 ], [ %t2.10, %if.end67 ]
241  %tobool96 = icmp eq i32 undef, 0
242  br i1 %tobool96, label %cleanup100, label %for.cond98
243
244for.cond98:                                       ; preds = %for.cond98, %for.end95, %cleanup75
245  br label %for.cond98
246
247cleanup100:                                       ; preds = %for.end95, %if.then73, %if.then38
248  %t7.19 = phi i16 [ %t7.18, %for.end95 ], [ %tmp5, %if.then38 ], [ %t7.12, %if.then73 ]
249  %t2.18 = phi i32 [ %t2.17, %for.end95 ], [ %t2.7, %if.then38 ], [ undef, %if.then73 ]
250  switch i32 undef, label %unreachable [
251    i32 0, label %for.cond
252    i32 17, label %L1
253    i32 7, label %cleanup100.L5_crit_edge
254  ]
255
256cleanup100.L5_crit_edge:                          ; preds = %cleanup100
257  %.pre.pre = load i32, i32* @r, align 4
258  br label %L5
259
260unreachable:                                      ; preds = %cleanup100
261  unreachable
262}
263
264; Function Attrs: nounwind
265declare void @printf(i8* nocapture readonly, ...) #1
266
267attributes #0 = { noreturn nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
268attributes #1 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
269