aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-12 19:20:37 +0000
committerDan Gohman <gohman@apple.com>2010-02-12 19:20:37 +0000
commitcd045c08cad9bc3e1e3e234453f5f4464b705e02 (patch)
treef39dfba1296efbcafb401d021b3607e827644cb7 /lib/Transforms
parentb98e16031841b3536a03ca4072fb241ff32c517e (diff)
downloadexternal_llvm-cd045c08cad9bc3e1e3e234453f5f4464b705e02.zip
external_llvm-cd045c08cad9bc3e1e3e234453f5f4464b705e02.tar.gz
external_llvm-cd045c08cad9bc3e1e3e234453f5f4464b705e02.tar.bz2
Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 73d3f9d..a218af9 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2271,6 +2271,10 @@ void LSRInstance::GenerateCrossUseConstantOffsets() {
const SCEV *Reg = *I;
const ImmMapTy &Imms = Map.find(Reg)->second;
+ // It's not worthwhile looking for reuse if there's only one offset.
+ if (Imms.size() == 1)
+ continue;
+
DEBUG(dbgs() << "Generating cross-use offsets for " << *Reg << ':';
for (ImmMapTy::const_iterator J = Imms.begin(), JE = Imms.end();
J != JE; ++J)
@@ -2299,7 +2303,7 @@ void LSRInstance::GenerateCrossUseConstantOffsets() {
};
for (size_t i = 0, e = array_lengthof(OtherImms); i != e; ++i) {
ImmMapTy::const_iterator M = OtherImms[i];
- if (M == J) continue;
+ if (M == J || M == JE) continue;
// Compute the difference between the two.
int64_t Imm = (uint64_t)JImm - M->first;