From 1a6111f32dcc1f4b0bc5993a09af4adb65a23b3f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 16 Nov 2008 07:17:51 +0000 Subject: [PATCH] eliminate some std::set's. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59409 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/IndVarSimplify.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 56829bd60ca..2af10a6f7b2 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -53,6 +53,7 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Support/CommandLine.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Statistic.h" using namespace llvm; @@ -87,12 +88,12 @@ namespace { private: void EliminatePointerRecurrence(PHINode *PN, BasicBlock *Preheader, - std::set &DeadInsts); + SmallPtrSet &DeadInsts); Instruction *LinearFunctionTestReplace(Loop *L, SCEV *IterationCount, SCEVExpander &RW); void RewriteLoopExitValues(Loop *L, SCEV *IterationCount); - void DeleteTriviallyDeadInstructions(std::set &Insts); + void DeleteTriviallyDeadInstructions(SmallPtrSet &Insts); void OptimizeCanonicalIVType(Loop *L); void HandleFloatingPointIV(Loop *L); @@ -111,10 +112,10 @@ Pass *llvm::createIndVarSimplifyPass() { /// specified set are trivially dead, delete them and see if this makes any of /// their operands subsequently dead. void IndVarSimplify:: -DeleteTriviallyDeadInstructions(std::set &Insts) { +DeleteTriviallyDeadInstructions(SmallPtrSet &Insts) { while (!Insts.empty()) { Instruction *I = *Insts.begin(); - Insts.erase(Insts.begin()); + Insts.erase(I); if (isInstructionTriviallyDead(I)) { for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) if (Instruction *U = dyn_cast(I->getOperand(i))) @@ -133,7 +134,7 @@ DeleteTriviallyDeadInstructions(std::set &Insts) { /// analysis by the SCEV routines. void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN, BasicBlock *Preheader, - std::set &DeadInsts) { + SmallPtrSet &DeadInsts) { assert(PN->getNumIncomingValues() == 2 && "Noncanonicalized loop!"); unsigned PreheaderIdx = PN->getBasicBlockIndex(Preheader); unsigned BackedgeIdx = PreheaderIdx^1; @@ -326,7 +327,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L, SCEV *IterationCount) { bool HasConstantItCount = isa(IterationCount); - std::set InstructionsToDelete; + SmallPtrSet InstructionsToDelete; std::map ExitValues; // Find all values that are computed inside the loop, but used outside of it. @@ -427,7 +428,7 @@ bool IndVarSimplify::doInitialization(Loop *L, LPPassManager &LPM) { BasicBlock *Preheader = L->getLoopPreheader(); SE = &LPM.getAnalysis(); - std::set DeadInsts; + SmallPtrSet DeadInsts; for (BasicBlock::iterator I = Header->begin(); isa(I); ++I) { PHINode *PN = cast(I); if (isa(PN->getType())) @@ -448,7 +449,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { Changed = false; BasicBlock *Header = L->getHeader(); - std::set DeadInsts; + SmallPtrSet DeadInsts; // Verify the input to the pass in already in LCSSA form. assert(L->isLCSSAForm()); @@ -495,7 +496,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { IterationCount->getType()); if (Instruction *I = LinearFunctionTestReplace(L, IterationCount, Rewriter)) { - std::set InstructionsToDelete; + SmallPtrSet InstructionsToDelete; InstructionsToDelete.insert(I); DeleteTriviallyDeadInstructions(InstructionsToDelete); }