brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.7 KiB · 9f51fa4 Raw
269 lines · plain
1; RUN: llc %s -o - | FileCheck %s2; This file checks some weird corner case in LiveRangeEdit.3; We used to do crash when we eliminate the definition4; of the product of splitting when the original live-range5; has already been removed.6; Basically, we have the following input.7; v1 = loadimm cst8; ...9; = use v110;11; We split the live-range like this:12; v1 = loadimm cst13; ...14; v2 = copy v115; ...16; = use v217;18; We actually issue loadimm instead of the copy:19; v1 = loadimm cst20; ...21; v2 = loadimm cst 22; ...23; = use v224;25; v1 is now dead so we remove its live-range.26; Actually, we shrink it to empty to keep the27; instruction around for futher remat opportunities28; (accessbile via the origin pointer.)29;30; Later v2 gets remove as well (e.g., because we31; remat it closer to its use) and the live-range32; gets eliminated. We used to crash at this point33; 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 the36; live-range is now empty... crash!37; PR2798338 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 444@k = external global i32, align 445@g = external global i32, align 446@a = external global i16, align 247@p = external global i32, align 448@n = external global i16, align 249@.str = external unnamed_addr constant [12 x i8], align 150@.str.1 = external unnamed_addr constant [13 x i8], align 151@s = external global i32, align 452@z = external global i16, align 253 54; CHECK-LABEL: fn1:55define void @fn1() #0 {56entry:57  br label %for.cond58 59for.cond:                                         ; preds = %cleanup100, %for.end29, %entry60  %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, ptr @r, align 464  br i1 undef, label %if.then, label %if.end765 66if.then:                                          ; preds = %for.cond67  %tobool = icmp ne i32 %tmp, 068  %tobool1 = icmp ne i32 %t2.0, 069  %tmp1 = and i1 %tobool1, %tobool70  %land.ext = zext i1 %tmp1 to i3271  %tmp2 = load i32, ptr @k, align 472  %shr = lshr i32 %land.ext, %tmp273  %tobool4 = icmp ne i32 %shr, 074  %or.cond = and i1 false, %tobool475  br i1 %or.cond, label %L6, label %if.end776 77if.end7:                                          ; preds = %if.then, %for.cond78  %t2.1 = phi i32 [ %shr, %if.then ], [ %t2.0, %for.cond ]79  %tobool8 = icmp eq i32 undef, 080  br i1 %tobool8, label %if.end11, label %for.cond1081 82for.cond10:                                       ; preds = %for.cond10, %if.end783  br label %for.cond1084 85if.end11:                                         ; preds = %if.end786  %tmp3 = load i32, ptr @g, align 487  %tmp4 = load i16, ptr @a, align 288  %conv = sext i16 %tmp4 to i3289  %div = sdiv i32 %tmp3, %conv90  %tobool12 = icmp eq i32 %div, 091  br i1 %tobool12, label %for.cond15, label %L592 93for.cond15:                                       ; preds = %for.cond17, %if.end1194  %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, 097  br i1 %tobool16, label %for.end29, label %for.cond1798 99for.cond17:                                       ; preds = %for.cond20, %for.cond15100  %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, 0103  br i1 %tobool18, label %for.cond15, label %for.cond20104 105for.cond20:                                       ; preds = %for.cond23, %for.cond17106  %t7.3 = phi i16 [ %t7.4, %for.cond23 ], [ %t7.2, %for.cond17 ]107  %tobool21 = icmp eq i32 undef, 0108  br i1 %tobool21, label %for.cond17, label %for.cond23109 110for.cond23:                                       ; preds = %L1, %for.cond20111  %t7.4 = phi i16 [ %t7.5, %L1 ], [ %t7.3, %for.cond20 ]112  %tobool24 = icmp eq i8 undef, 0113  br i1 %tobool24, label %for.cond20, label %L1114 115L1:                                               ; preds = %cleanup100, %for.cond23116  %t7.5 = phi i16 [ %t7.19, %cleanup100 ], [ %t7.4, %for.cond23 ]117  %conv26 = sext i16 undef to i64118  br label %for.cond23119 120for.end29:                                        ; preds = %for.cond15121  br i1 undef, label %for.cond, label %for.cond32thread-pre-split122 123for.cond32thread-pre-split:                       ; preds = %for.end29124  %.pr = load i32, ptr @p, align 4125  br label %for.cond32126 127for.cond32:                                       ; preds = %for.inc94, %for.cond32thread-pre-split128  %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, 0133  br i1 %tobool33, label %for.end95, label %for.body34134 135for.body34:                                       ; preds = %for.cond32136  %tobool35 = icmp eq i16 undef, 0137  br i1 %tobool35, label %for.inc94, label %if.then36138 139if.then36:                                        ; preds = %for.body34140  %tmp5 = load i16, ptr @n, align 2141  %tobool37 = icmp eq i32 undef, 0142  br i1 %tobool37, label %if.end78, label %if.then38143 144if.then38:                                        ; preds = %if.then36145  tail call void (ptr, ...) @printf(ptr @.str, i64 undef)146  %tobool40 = icmp eq i32 undef, 0147  br i1 %tobool40, label %L3, label %cleanup100148 149L3:                                               ; preds = %while.end.split, %if.then38150  %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, 0154  br i1 %tobool43, label %if.end48, label %cleanup75155 156if.end48:                                         ; preds = %L3157  tail call void (ptr, ...) @printf(ptr @.str.1, i64 %t3.5)158  br i1 undef, label %if.end61, label %for.cond52.preheader159 160for.cond52.preheader:                             ; preds = %if.end48161  %tobool57 = icmp eq i16 undef, 0162  %.130 = select i1 %tobool57, i16 -8, i16 0163  br label %if.end61164 165if.end61:                                         ; preds = %for.cond52.preheader, %if.end48166  %t7.9 = phi i16 [ %t7.7, %if.end48 ], [ %.130, %for.cond52.preheader ]167  %tobool62 = icmp eq i32 undef, 0168  br i1 %tobool62, label %if.end71, label %if.then63169 170if.then63:                                        ; preds = %if.end61171  br i1 undef, label %if.end67, label %L5172 173L5:                                               ; preds = %cleanup100.L5_crit_edge, %if.then63, %if.end11174  %.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, ptr @s, align 4180  br label %if.end67181 182if.end67:                                         ; preds = %L5, %if.then63183  %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, 0189  br i1 %tobool68, label %if.end71, label %for.end95190 191if.end71:                                         ; preds = %if.end67, %if.end61192  %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, 0195  br i1 %tobool72, label %cleanup75.thread128, label %if.then73196 197if.then73:                                        ; preds = %if.end71198  br label %cleanup100199 200cleanup75.thread128:                              ; preds = %if.end71201  br label %if.end78202 203cleanup75:                                        ; preds = %L3204  br i1 false, label %for.cond98, label %for.end95205 206if.end78:                                         ; preds = %cleanup75.thread128, %if.then36207  %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, ptr @z, align 2212  br label %L6213 214L6:                                               ; preds = %if.end78, %if.then215  %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.inc94220 221while.condthread-pre-split:                       ; preds = %L6222  %tobool83 = icmp eq i32 undef, 0223  br i1 %tobool83, label %while.end.split, label %while.cond224 225while.cond:                                       ; preds = %while.cond, %while.condthread-pre-split226  br label %while.cond227 228while.end.split:                                  ; preds = %while.condthread-pre-split229  %tobool84 = icmp eq i16 undef, 0230  br i1 %tobool84, label %for.inc94, label %L3231 232for.inc94:                                        ; preds = %while.end.split, %L6, %for.body34233  %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, ptr @p, align 4236  br label %for.cond32237 238for.end95:                                        ; preds = %cleanup75, %if.end67, %for.cond32239  %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, 0242  br i1 %tobool96, label %cleanup100, label %for.cond98243 244for.cond98:                                       ; preds = %for.cond98, %for.end95, %cleanup75245  br label %for.cond98246 247cleanup100:                                       ; preds = %for.end95, %if.then73, %if.then38248  %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.cond252    i32 17, label %L1253    i32 7, label %cleanup100.L5_crit_edge254  ]255 256cleanup100.L5_crit_edge:                          ; preds = %cleanup100257  %.pre.pre = load i32, ptr @r, align 4258  br label %L5259 260unreachable:                                      ; preds = %cleanup100261  unreachable262}263 264; Function Attrs: nounwind265declare void @printf(ptr nocapture readonly, ...) #1266 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" "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" "use-soft-float"="false" }269