Skip to content

Commit eea45bf

Browse files
committed
Merge from mainline, bugfix for PR185
llvm-svn: 10474
1 parent be0de4d commit eea45bf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Support/Debug.h"
2727
#include "Support/Statistic.h"
2828
#include "Support/STLExtras.h"
29+
#include <algorithm>
2930
using namespace llvm;
3031

3132
namespace {
@@ -206,6 +207,14 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
206207
PHIOps.insert(PHIOps.end(), MaybeDead->op_begin(),
207208
MaybeDead->op_end());
208209
MaybeDead->getParent()->getInstList().erase(MaybeDead);
210+
211+
// Erase any duplicates entries in the PHIOps list.
212+
std::vector<Value*>::iterator It =
213+
std::find(PHIOps.begin(), PHIOps.end(), MaybeDead);
214+
while (It != PHIOps.end()) {
215+
PHIOps.erase(It);
216+
It = std::find(PHIOps.begin(), PHIOps.end(), MaybeDead);
217+
}
209218

210219
// Erasing the instruction could invalidate the AfterPHI iterator!
211220
AfterPHIIt = Header->begin();

0 commit comments

Comments
 (0)