[llvm-branch-commits] [llvm-branch] r276688 - Merging r276510:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 25 13:53:27 PDT 2016
Author: hans
Date: Mon Jul 25 15:53:27 2016
New Revision: 276688
URL: http://llvm.org/viewvc/llvm-project?rev=276688&view=rev
Log:
Merging r276510:
------------------------------------------------------------------------
r276510 | majnemer | 2016-07-22 19:56:49 -0700 (Fri, 22 Jul 2016) | 9 lines
[LoopUnrollAnalyzer] Handle out of bounds accesses in visitLoad
While we handed loads past the end of an array, we didn't handle loads
_before_ the array.
This fixes PR28062.
N.B. While the bug in the code is obvious, I am struggling to craft a
test case which is reasonable in size.
------------------------------------------------------------------------
Modified:
llvm/branches/release_39/ (props changed)
llvm/branches/release_39/lib/Analysis/LoopUnrollAnalyzer.cpp
Propchange: llvm/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 25 15:53:27 2016
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,275870,275879,275898,275928,275935,275946,276077,276181,276236-276237,276358,276364,276368,276389,276438,276479
+/llvm/trunk:155241,275870,275879,275898,275928,275935,275946,276077,276181,276236-276237,276358,276364,276368,276389,276438,276479,276510
Modified: llvm/branches/release_39/lib/Analysis/LoopUnrollAnalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Analysis/LoopUnrollAnalyzer.cpp?rev=276688&r1=276687&r2=276688&view=diff
==============================================================================
--- llvm/branches/release_39/lib/Analysis/LoopUnrollAnalyzer.cpp (original)
+++ llvm/branches/release_39/lib/Analysis/LoopUnrollAnalyzer.cpp Mon Jul 25 15:53:27 2016
@@ -115,13 +115,19 @@ bool UnrolledInstAnalyzer::visitLoad(Loa
// We might have a vector load from an array. FIXME: for now we just bail
// out in this case, but we should be able to resolve and simplify such
// loads.
- if(CDS->getElementType() != I.getType())
+ if (CDS->getElementType() != I.getType())
return false;
- int ElemSize = CDS->getElementType()->getPrimitiveSizeInBits() / 8U;
- if (SimplifiedAddrOp->getValue().getActiveBits() >= 64)
+ unsigned ElemSize = CDS->getElementType()->getPrimitiveSizeInBits() / 8U;
+ if (SimplifiedAddrOp->getValue().getActiveBits() > 64)
return false;
- int64_t Index = SimplifiedAddrOp->getSExtValue() / ElemSize;
+ int64_t SimplifiedAddrOpV = SimplifiedAddrOp->getSExtValue();
+ if (SimplifiedAddrOpV < 0) {
+ // FIXME: For now we conservatively ignore out of bound accesses, but
+ // we're allowed to perform the optimization in this case.
+ return false;
+ }
+ uint64_t Index = static_cast<uint64_t>(SimplifiedAddrOpV) / ElemSize;
if (Index >= CDS->getNumElements()) {
// FIXME: For now we conservatively ignore out of bound accesses, but
// we're allowed to perform the optimization in this case.
More information about the llvm-branch-commits
mailing list