#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;
private:
void EliminatePointerRecurrence(PHINode *PN, BasicBlock *Preheader,
- std::set<Instruction*> &DeadInsts);
+ SmallPtrSet<Instruction*, 16> &DeadInsts);
Instruction *LinearFunctionTestReplace(Loop *L, SCEV *IterationCount,
SCEVExpander &RW);
void RewriteLoopExitValues(Loop *L, SCEV *IterationCount);
- void DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts);
+ void DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*, 16> &Insts);
void OptimizeCanonicalIVType(Loop *L);
void HandleFloatingPointIV(Loop *L);
/// specified set are trivially dead, delete them and see if this makes any of
/// their operands subsequently dead.
void IndVarSimplify::
-DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
+DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*, 16> &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<Instruction>(I->getOperand(i)))
/// analysis by the SCEV routines.
void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
BasicBlock *Preheader,
- std::set<Instruction*> &DeadInsts) {
+ SmallPtrSet<Instruction*, 16> &DeadInsts) {
assert(PN->getNumIncomingValues() == 2 && "Noncanonicalized loop!");
unsigned PreheaderIdx = PN->getBasicBlockIndex(Preheader);
unsigned BackedgeIdx = PreheaderIdx^1;
bool HasConstantItCount = isa<SCEVConstant>(IterationCount);
- std::set<Instruction*> InstructionsToDelete;
+ SmallPtrSet<Instruction*, 16> InstructionsToDelete;
std::map<Instruction*, Value*> ExitValues;
// Find all values that are computed inside the loop, but used outside of it.
BasicBlock *Preheader = L->getLoopPreheader();
SE = &LPM.getAnalysis<ScalarEvolution>();
- std::set<Instruction*> DeadInsts;
+ SmallPtrSet<Instruction*, 16> DeadInsts;
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I);
if (isa<PointerType>(PN->getType()))
Changed = false;
BasicBlock *Header = L->getHeader();
- std::set<Instruction*> DeadInsts;
+ SmallPtrSet<Instruction*, 16> DeadInsts;
// Verify the input to the pass in already in LCSSA form.
assert(L->isLCSSAForm());
IterationCount->getType());
if (Instruction *I = LinearFunctionTestReplace(L, IterationCount,
Rewriter)) {
- std::set<Instruction*> InstructionsToDelete;
+ SmallPtrSet<Instruction*, 16> InstructionsToDelete;
InstructionsToDelete.insert(I);
DeleteTriviallyDeadInstructions(InstructionsToDelete);
}