diff options
| author | Michael Zolotukhin <mzolotukhin@apple.com> | 2016-05-27 00:55:16 +0000 | 
|---|---|---|
| committer | Michael Zolotukhin <mzolotukhin@apple.com> | 2016-05-27 00:55:16 +0000 | 
| commit | 15e745133eeca7a413308ad040a19aea5aad1d2b (patch) | |
| tree | ac45175eafae0ec91526058ace822f1481d77f8b | |
| parent | 0edb563f274876d97b6962ef088137936bc2893c (diff) | |
| download | bcm5719-llvm-15e745133eeca7a413308ad040a19aea5aad1d2b.tar.gz bcm5719-llvm-15e745133eeca7a413308ad040a19aea5aad1d2b.zip  | |
[LoopUnrollAnalyzer] Bail out instead of dying with assert when facing huge index.
This fixes PR27902.
llvm-svn: 270946
| -rw-r--r-- | llvm/lib/Analysis/LoopUnrollAnalyzer.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopUnroll/full-unroll-crashers.ll | 21 | 
2 files changed, 23 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp b/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp index d88ab163557..8a97a9f9522 100644 --- a/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp +++ b/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp @@ -119,8 +119,8 @@ bool UnrolledInstAnalyzer::visitLoad(LoadInst &I) {      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 diff --git a/llvm/test/Transforms/LoopUnroll/full-unroll-crashers.ll b/llvm/test/Transforms/LoopUnroll/full-unroll-crashers.ll index 00d12c289cc..a8e4329e599 100644 --- a/llvm/test/Transforms/LoopUnroll/full-unroll-crashers.ll +++ b/llvm/test/Transforms/LoopUnroll/full-unroll-crashers.ll @@ -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 +}  | 

