Commit eea45bf3 authored by Chris Lattner's avatar Chris Lattner
Browse files

Merge from mainline, bugfix for PR185

llvm-svn: 10474
parent be0de4d9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "Support/Debug.h"
#include "Support/Statistic.h"
#include "Support/STLExtras.h"
#include <algorithm>
using namespace llvm;

namespace {
@@ -207,6 +208,14 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
                        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();
        }