[llvm] r270946 - [LoopUnrollAnalyzer] Bail out instead of dying with assert when facing huge index.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 17:55:17 PDT 2016
Author: mzolotukhin
Date: Thu May 26 19:55:16 2016
New Revision: 270946
URL: http://llvm.org/viewvc/llvm-project?rev=270946&view=rev
Log:
[LoopUnrollAnalyzer] Bail out instead of dying with assert when facing huge index.
This fixes PR27902.
Modified:
llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp
llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll
Modified: llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp?rev=270946&r1=270945&r2=270946&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp Thu May 26 19:55:16 2016
@@ -119,8 +119,8 @@ bool UnrolledInstAnalyzer::visitLoad(Loa
return false;
int ElemSize = CDS->getElementType()->getPrimitiveSizeInBits() / 8U;
- assert(SimplifiedAddrOp->getValue().getActiveBits() < 64 &&
- "Unexpectedly large index value.");
+ if (SimplifiedAddrOp->getValue().getActiveBits() >= 64)
+ return false;
int64_t Index = SimplifiedAddrOp->getSExtValue() / ElemSize;
if (Index >= CDS->getNumElements()) {
// FIXME: For now we conservatively ignore out of bound accesses, but
Modified: llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll?rev=270946&r1=270945&r2=270946&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll Thu May 26 19:55:16 2016
@@ -167,3 +167,24 @@ for.inc:
for.end:
ret void
}
+
+define void @index_too_large() {
+entry:
+ br label %for.body
+
+for.body:
+ %iv = phi i64 [ -73631599, %entry ], [ %iv.next, %for.inc ]
+ br i1 undef, label %for.body2, label %for.inc
+
+for.body2:
+ %idx = getelementptr inbounds [10 x i32], [10 x i32]* @known_constant, i64 0, i64 %iv
+ %x = load i32, i32* %idx, align 1
+ br label %for.inc
+
+for.inc:
+ %iv.next = add nsw i64 %iv, -1
+ br i1 undef, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
More information about the llvm-commits
mailing list