Fix for PR185 & IndVarsSimplify/2003-12-15-Crash.llx

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10473 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-12-15 17:34:02 +00:00
parent 215da0c040
commit 9e45d2e0e8

View File

@ -26,6 +26,7 @@
#include "Support/Debug.h"
#include "Support/Statistic.h"
#include "Support/STLExtras.h"
#include <algorithm>
using namespace llvm;
namespace {
@ -206,6 +207,14 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
PHIOps.insert(PHIOps.end(), MaybeDead->op_begin(),
MaybeDead->op_end());
MaybeDead->getParent()->getInstList().erase(MaybeDead);
// Erase any duplicates entries in the PHIOps list.
std::vector<Value*>::iterator It =
std::find(PHIOps.begin(), PHIOps.end(), MaybeDead);
while (It != PHIOps.end()) {
PHIOps.erase(It);
It = std::find(PHIOps.begin(), PHIOps.end(), MaybeDead);
}
// Erasing the instruction could invalidate the AfterPHI iterator!
AfterPHIIt = Header->begin();