Skip to content

Commit d6c2ca8

Browse files
committed
[DeLICM] Avoid assertion on out-of-quota.
An assertion was not prepared to be passed a nullptr because the out-of-quota limit was exceeded. Bail-out before the assertion since the assertion does not apply on out-of-quote. This fixes llvm.org/PR37477. llvm-svn: 332488
1 parent 1238981 commit d6c2ca8

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

polly/lib/Support/ISLTools.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ isl::multi_aff makeShiftDimAff(isl::space Space, int Pos, int Amount) {
4747
/// @return { [Space1[] -> Space2[]] -> [Space2[] -> Space1[]] }
4848
isl::basic_map makeTupleSwapBasicMap(isl::space FromSpace1,
4949
isl::space FromSpace2) {
50+
// Fast-path on out-of-quota.
51+
if (!FromSpace1 || !FromSpace2)
52+
return {};
53+
5054
assert(FromSpace1.is_set());
5155
assert(FromSpace2.is_set());
5256

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
; RUN: opt %loadPolly -polly-delicm-max-ops=1000000 -polly-delicm -analyze < %s | FileCheck %s
2+
;
3+
; This causes an assertion to fail on out-of-quota after 1000000 operations.
4+
; (The error was specific to -polly-delicm-max-ops=1000000 and changes
5+
; in the implementation are likely to change the number of operations
6+
; up to the point where the error uses to occur)
7+
;
8+
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
9+
10+
define void @test(i32 %size, double* %lhs, i32 %lhsStride, double* %_rhs, double* %res, double %alpha) {
11+
entry:
12+
br label %if.end
13+
14+
if.end: ; preds = %entry
15+
%sub = add nsw i32 %size, -8
16+
%cmp.i.i.i = icmp sgt i32 %sub, 0
17+
%.sroa.speculated = select i1 %cmp.i.i.i, i32 %sub, i32 0
18+
%and36 = and i32 %.sroa.speculated, -2
19+
%cmp38463 = icmp sgt i32 %and36, 0
20+
br i1 %cmp38463, label %for.body40, label %for.cond177.preheader
21+
22+
for.cond177.preheader: ; preds = %for.cond.cleanup142, %if.end
23+
br label %for.body180
24+
25+
for.body40: ; preds = %for.cond.cleanup142, %if.end
26+
%j.0464 = phi i32 [ %add55, %for.cond.cleanup142 ], [ 0, %if.end ]
27+
%mul41 = mul nsw i32 %j.0464, %lhsStride
28+
%add.ptr42 = getelementptr inbounds double, double* %lhs, i32 %mul41
29+
%add43 = or i32 %j.0464, 1
30+
%arrayidx46 = getelementptr inbounds double, double* %_rhs, i32 %j.0464
31+
%tmp = load double, double* %arrayidx46, align 8
32+
%mul47 = fmul double %tmp, %alpha
33+
%add55 = add nuw nsw i32 %j.0464, 2
34+
%arrayidx67 = getelementptr inbounds double, double* %res, i32 %j.0464
35+
%tmp1 = load double, double* %arrayidx67, align 8
36+
store double undef, double* %arrayidx67, align 8
37+
%arrayidx75 = getelementptr inbounds double, double* %res, i32 %add43
38+
%tmp2 = load double, double* %arrayidx75, align 8
39+
store double undef, double* %arrayidx75, align 8
40+
%arrayidx78 = getelementptr inbounds double, double* %add.ptr42, i32 %add43
41+
%tmp3 = load double, double* %arrayidx78, align 8
42+
%mul.i.i388 = fmul double %mul47, %tmp3
43+
%add88 = fadd double undef, 0.000000e+00
44+
%cmp120448 = icmp ult i32 %add55, %size
45+
br i1 %cmp120448, label %for.body122.preheader, label %for.cond.cleanup142
46+
47+
for.body122.preheader: ; preds = %for.body40
48+
%add.ptr117 = getelementptr inbounds double, double* %res, i32 %add55
49+
br label %for.body122
50+
51+
for.body122: ; preds = %for.body122, %for.body122.preheader
52+
%i118.0455 = phi i32 [ %add137, %for.body122 ], [ %add55, %for.body122.preheader ]
53+
%resIt.0454 = phi double* [ %add.ptr135, %for.body122 ], [ %add.ptr117, %for.body122.preheader ]
54+
%ptmp2.0450 = phi double [ undef, %for.body122 ], [ 0.000000e+00, %for.body122.preheader ]
55+
%tmp4 = load double, double* %resIt.0454, align 8
56+
%add.i.i.i386 = fadd double undef, %tmp4
57+
%add.i.i.i384 = fadd double undef, %add.i.i.i386
58+
store double %add.i.i.i384, double* %resIt.0454, align 8
59+
%add.ptr135 = getelementptr inbounds double, double* %resIt.0454, i32 1
60+
%add137 = add nuw i32 %i118.0455, 1
61+
%exitcond469 = icmp eq i32 %add137, %size
62+
br i1 %exitcond469, label %for.cond.cleanup142.loopexit, label %for.body122
63+
64+
for.cond.cleanup142.loopexit: ; preds = %for.body122
65+
%.pre = load double, double* %arrayidx67, align 8
66+
%.pre471 = load double, double* %arrayidx75, align 8
67+
br label %for.cond.cleanup142
68+
69+
for.cond.cleanup142: ; preds = %for.cond.cleanup142.loopexit, %for.body40
70+
%tmp5 = phi double [ undef, %for.body40 ], [ %.pre471, %for.cond.cleanup142.loopexit ]
71+
%tmp6 = phi double [ undef, %for.body40 ], [ %.pre, %for.cond.cleanup142.loopexit ]
72+
%ptmp2.0.lcssa = phi double [ 0.000000e+00, %for.body40 ], [ undef, %for.cond.cleanup142.loopexit ]
73+
%add163 = fadd double %add88, %ptmp2.0.lcssa
74+
store double undef, double* %arrayidx67, align 8
75+
store double undef, double* %arrayidx75, align 8
76+
%cmp38 = icmp ult i32 %add55, %and36
77+
br i1 %cmp38, label %for.body40, label %for.cond177.preheader
78+
79+
for.cond.cleanup179: ; preds = %for.cond.cleanup198
80+
ret void
81+
82+
for.body180: ; preds = %for.cond.cleanup198, %for.cond177.preheader
83+
%j176.0442 = phi i32 [ %add195, %for.cond.cleanup198 ], [ %and36, %for.cond177.preheader ]
84+
%add.ptr183 = getelementptr inbounds double, double* %lhs, i32 0
85+
%arrayidx185 = getelementptr inbounds double, double* %_rhs, i32 %j176.0442
86+
%tmp7 = load double, double* %arrayidx185, align 8
87+
%mul186 = fmul double %tmp7, %alpha
88+
%arrayidx189 = getelementptr inbounds double, double* %add.ptr183, i32 %j176.0442
89+
%tmp8 = load double, double* %arrayidx189, align 8
90+
%mul.i.i373 = fmul double %tmp8, %mul186
91+
%arrayidx192 = getelementptr inbounds double, double* %res, i32 %j176.0442
92+
%tmp9 = load double, double* %arrayidx192, align 8
93+
%add193 = fadd double %tmp9, %mul.i.i373
94+
store double %add193, double* %arrayidx192, align 8
95+
%add195 = add nuw nsw i32 %j176.0442, 1
96+
%cmp197438 = icmp slt i32 %add195, %size
97+
br i1 %cmp197438, label %for.body199, label %for.cond.cleanup198
98+
99+
for.cond.cleanup198.loopexit: ; preds = %for.body199
100+
%.pre472 = load double, double* %arrayidx192, align 8
101+
br label %for.cond.cleanup198
102+
103+
for.cond.cleanup198: ; preds = %for.cond.cleanup198.loopexit, %for.body180
104+
%tmp10 = phi double [ %add193, %for.body180 ], [ %.pre472, %for.cond.cleanup198.loopexit ]
105+
%t2187.0.lcssa = phi double [ 0.000000e+00, %for.body180 ], [ %add207, %for.cond.cleanup198.loopexit ]
106+
%add213 = fadd double %tmp10, undef
107+
store double %add213, double* %arrayidx192, align 8
108+
%exitcond468 = icmp eq i32 %add195, %size
109+
br i1 %exitcond468, label %for.cond.cleanup179, label %for.body180
110+
111+
for.body199: ; preds = %for.body199, %for.body180
112+
%i194.0440 = phi i32 [ %inc209, %for.body199 ], [ %add195, %for.body180 ]
113+
%arrayidx200 = getelementptr inbounds double, double* %add.ptr183, i32 %i194.0440
114+
%tmp11 = load double, double* %arrayidx200, align 8
115+
%mul.i.i372 = fmul double %mul186, %tmp11
116+
%arrayidx202 = getelementptr inbounds double, double* %res, i32 %i194.0440
117+
%tmp12 = load double, double* %arrayidx202, align 8
118+
%add203 = fadd double %tmp12, %mul.i.i372
119+
store double %add203, double* %arrayidx202, align 8
120+
%arrayidx205 = getelementptr inbounds double, double* %_rhs, i32 %i194.0440
121+
%tmp13 = load double, double* %arrayidx200, align 8
122+
%tmp14 = load double, double* %arrayidx205, align 8
123+
%mul.i.i = fmul double %tmp13, %tmp14
124+
%add207 = fadd double undef, %mul.i.i
125+
%inc209 = add nuw nsw i32 %i194.0440, 1
126+
%exitcond = icmp eq i32 %inc209, %size
127+
br i1 %exitcond, label %for.cond.cleanup198.loopexit, label %for.body199
128+
}
129+
130+
131+
; CHECK: Zone not computed

0 commit comments

Comments
 (0)