X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FCFG.cpp;h=8ef5302717f8ab0702314fb64b8d15f6025a71d7;hb=cfc42962c8c730d62c8483d351843802a1aca802;hp=c3f32d3a840c82b34b56eae64b172607c0c57220;hpb=328a4fbfbb778de44d9a738c3efdfd42a58925d9;p=oota-llvm.git diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index c3f32d3a840..8ef5302717f 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -13,10 +13,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/CFG.h" - #include "llvm/ADT/SmallSet.h" -#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/IR/Dominators.h" using namespace llvm; @@ -102,15 +101,9 @@ bool llvm::isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum, // If AllowIdenticalEdges is true, then we allow this edge to be considered // non-critical iff all preds come from TI's block. - while (I != E) { - const BasicBlock *P = *I; - if (P != FirstPred) + for (; I != E; ++I) + if (*I != FirstPred) return true; - // Note: leave this as is until no one ever compiles with either gcc 4.0.1 - // or Xcode 2. This seems to work around the pred_iterator assert in PR 2207 - E = pred_end(P); - ++I; - } return false; } @@ -130,7 +123,7 @@ static bool loopContainsBoth(const LoopInfo *LI, const BasicBlock *BB1, const BasicBlock *BB2) { const Loop *L1 = getOutermostLoop(LI, BB1); const Loop *L2 = getOutermostLoop(LI, BB2); - return L1 != NULL && L1 == L2; + return L1 != nullptr && L1 == L2; } static bool isPotentiallyReachableInner(SmallVectorImpl &Worklist, @@ -140,7 +133,7 @@ static bool isPotentiallyReachableInner(SmallVectorImpl &Worklist, // When the stop block is unreachable, it's dominated from everywhere, // regardless of whether there's a path between the two blocks. if (DT && !DT->isReachableFromEntry(StopBB)) - DT = 0; + DT = nullptr; // Limit the number of blocks we visit. The goal is to avoid run-away compile // times on large CFGs without hampering sensible code. Arbitrarily chosen. @@ -163,14 +156,13 @@ static bool isPotentiallyReachableInner(SmallVectorImpl &Worklist, return true; } - if (const Loop *Outer = LI ? getOutermostLoop(LI, BB) : 0) { + if (const Loop *Outer = LI ? getOutermostLoop(LI, BB) : nullptr) { // All blocks in a single loop are reachable from all other blocks. From // any of these blocks, we can skip directly to the exits of the loop, // ignoring any other blocks inside the loop body. Outer->getExitBlocks(Worklist); } else { - for (succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I) - Worklist.push_back(*I); + Worklist.append(succ_begin(BB), succ_end(BB)); } } while (!Worklist.empty()); @@ -208,7 +200,7 @@ bool llvm::isPotentiallyReachable(const Instruction *A, const Instruction *B, // If the block is in a loop then we can reach any instruction in the block // from any other instruction in the block by going around a backedge. - if (LI && LI->getLoopFor(BB) != 0) + if (LI && LI->getLoopFor(BB) != nullptr) return true; // Linear scan, start at 'A', see whether we hit 'B' or the end first. @@ -223,8 +215,7 @@ bool llvm::isPotentiallyReachable(const Instruction *A, const Instruction *B, return false; // Otherwise, continue doing the normal per-BB CFG walk. - for (succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I) - Worklist.push_back(*I); + Worklist.append(succ_begin(BB), succ_end(BB)); if (Worklist.empty()) { // We've proven that there's no path!