summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2013-02-17 15:59:26 +0000
committerHal Finkel <hfinkel@anl.gov>2013-02-17 15:59:26 +0000
commit76e65e45425a63f8915a389a7a385cac3aae52bf (patch)
treec5f3b2c0458a9c1fa270b58f89d85b6b6188f660 /llvm/lib/Transforms
parentdfe49e8c310b3c571ef80fe6f3399724a6ff5f24 (diff)
downloadbcm5719-llvm-76e65e45425a63f8915a389a7a385cac3aae52bf.tar.gz
bcm5719-llvm-76e65e45425a63f8915a389a7a385cac3aae52bf.zip
BBVectorize: Fix an invalid reference bug
This fixes PR15289. This bug was introduced (recently) in r175215; collecting all std::vector references for candidate pairs to delete at once is invalid because subsequent lookups in the owning DenseMap could invalidate the references. bugpoint was able to reduce a useful test case. Unfortunately, because whether or not this asserts depends on memory layout, this test case will sometimes appear to produce valid output. Nevertheless, running under valgrind will reveal the error. llvm-svn: 175397
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/BBVectorize.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
index 1773cff3bb7..76365417aa8 100644
--- a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -2164,10 +2164,7 @@ namespace {
*S->second << "\n");
// Remove all candidate pairs that have values in the chosen dag.
- std::vector<Value *> &KK = CandidatePairs[S->first],
- &LL = CandidatePairs2[S->second],
- &MM = CandidatePairs[S->second],
- &NN = CandidatePairs2[S->first];
+ std::vector<Value *> &KK = CandidatePairs[S->first];
for (std::vector<Value *>::iterator K = KK.begin(), KE = KK.end();
K != KE; ++K) {
if (*K == S->second)
@@ -2175,6 +2172,8 @@ namespace {
CandidatePairsSet.erase(ValuePair(S->first, *K));
}
+
+ std::vector<Value *> &LL = CandidatePairs2[S->second];
for (std::vector<Value *>::iterator L = LL.begin(), LE = LL.end();
L != LE; ++L) {
if (*L == S->first)
@@ -2182,11 +2181,15 @@ namespace {
CandidatePairsSet.erase(ValuePair(*L, S->second));
}
+
+ std::vector<Value *> &MM = CandidatePairs[S->second];
for (std::vector<Value *>::iterator M = MM.begin(), ME = MM.end();
M != ME; ++M) {
assert(*M != S->first && "Flipped pair in candidate list?");
CandidatePairsSet.erase(ValuePair(S->second, *M));
}
+
+ std::vector<Value *> &NN = CandidatePairs2[S->first];
for (std::vector<Value *>::iterator N = NN.begin(), NE = NN.end();
N != NE; ++N) {
assert(*N != S->second && "Flipped pair in candidate list?");
OpenPOWER on IntegriCloud