summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-01-02 00:10:22 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-01-02 00:10:22 +0000
commit29c22fae46d5e314e60225baf7ceb5975bf18bad (patch)
tree73789567a93e2ed8b9f5da32cf34d8e25fb48665 /llvm/lib/Transforms
parentc39eaa50411d1e90065564a912cc420c2733bf6a (diff)
downloadbcm5719-llvm-29c22fae46d5e314e60225baf7ceb5975bf18bad.tar.gz
bcm5719-llvm-29c22fae46d5e314e60225baf7ceb5975bf18bad.zip
[SROA] Fix the loop exit placement to be prior to indexing the splits
array. This prevents it from walking out of bounds on the splits array. Bug found with the existing tests by ASan and by the MSVC debug build. llvm-svn: 225069
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 683fab5cb65..3d00f38f7ef 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3706,11 +3706,13 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
<< ", " << NewSlices.back().endOffset() << "): " << *PLoad
<< "\n");
+ // See if we've handled all the splits.
+ if (Idx >= Size)
+ break;
+
// Setup the next partition.
PartOffset = Offsets.Splits[Idx];
++Idx;
- if (Idx > Size)
- break;
PartSize = (Idx < Size ? Offsets.Splits[Idx] : LoadSize) - PartOffset;
}
@@ -3845,11 +3847,13 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
DEBUG(dbgs() << " of split load: " << *PLoad << "\n");
}
+ // See if we've finished all the splits.
+ if (Idx >= Size)
+ break;
+
// Setup the next partition.
PartOffset = Offsets.Splits[Idx];
++Idx;
- if (Idx > Size)
- break;
PartSize = (Idx < Size ? Offsets.Splits[Idx] : StoreSize) - PartOffset;
}
OpenPOWER on IntegriCloud