diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-04-30 20:52:49 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-04-30 20:52:49 +0000 | 
| commit | f328577307add65a4c6063dd772f6f3ed53d0c0c (patch) | |
| tree | 73cbbb93e21144b949ac09d720b39dfc25855c9c /llvm | |
| parent | 12fc22300ec7f230d5b01f92cef26b8f51f2fd35 (diff) | |
| download | bcm5719-llvm-f328577307add65a4c6063dd772f6f3ed53d0c0c.tar.gz bcm5719-llvm-f328577307add65a4c6063dd772f6f3ed53d0c0c.zip | |
Remove unneccesary pass
llvm-svn: 2420
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/HoistPHIConstants.cpp | 86 | 
1 files changed, 0 insertions, 86 deletions
| diff --git a/llvm/lib/Transforms/HoistPHIConstants.cpp b/llvm/lib/Transforms/HoistPHIConstants.cpp deleted file mode 100644 index bdf2efc952b..00000000000 --- a/llvm/lib/Transforms/HoistPHIConstants.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===- llvm/Transforms/HoistPHIConstants.h - Normalize PHI nodes ------------=// -// -// HoistPHIConstants - Remove literal constants that are arguments of PHI nodes -// by inserting cast instructions in the preceeding basic blocks, and changing -// constant references into references of the casted value. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Transforms/HoistPHIConstants.h" -#include "llvm/iPHINode.h" -#include "llvm/iOther.h" -#include "llvm/BasicBlock.h" -#include "llvm/Function.h" -#include "llvm/Pass.h" - -typedef std::pair<BasicBlock *, Value*> BBConstTy; -typedef std::map<BBConstTy, CastInst *> CachedCopyMap; - -static Value *NormalizePhiOperand(PHINode *PN, Value *CPV, -                                  BasicBlock *Pred, CachedCopyMap &CopyCache) { -  // Check if we've already inserted a copy for this constant in Pred -  // Note that `copyCache[Pred]' will create an empty vector the first time -  // -  CachedCopyMap::iterator CCI = CopyCache.find(BBConstTy(Pred, CPV)); -  if (CCI != CopyCache.end()) return CCI->second; -   -  // Create a copy instruction and add it to the cache... -  CastInst *Inst = new CastInst(CPV, CPV->getType()); -  CopyCache.insert(std::make_pair(BBConstTy(Pred, CPV), Inst)); -     -  // Insert the copy just before the terminator inst of the predecessor BB -  assert(Pred->getTerminator() && "Degenerate BB encountered!"); -  Pred->getInstList().insert(Pred->getInstList().end()-1, Inst); -   -  return Inst; -} - - -//--------------------------------------------------------------------------- -// Entry point for normalizing constant args in PHIs -//--------------------------------------------------------------------------- - -static bool doHoistPHIConstants(Function *M) { -  CachedCopyMap Cache; -  bool Changed = false; -   -  for (Function::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) { -    std::vector<PHINode*> phis;          // normalizing invalidates BB iterator -       -    for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) { -      if (PHINode *PN = dyn_cast<PHINode>(*II)) -        phis.push_back(PN); -      else -        break;                      // All PHIs occur at top of BB! -    } -       -    for (std::vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end();++PI) -      for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) { -        Value *Op = (*PI)->getIncomingValue(i); -         -        if (isa<Constant>(Op)) { -          (*PI)->setIncomingValue(i, -                    NormalizePhiOperand((*PI), -                                        (*PI)->getIncomingValue(i), -                                        (*PI)->getIncomingBlock(i), Cache)); -          Changed = true; -        } -      } -  } -   -  return Changed; -} - -namespace { -  struct HoistPHIConstants : public FunctionPass { -    const char *getPassName() const { return "Hoist Constants from PHI Nodes"; } - -    virtual bool runOnFunction(Function *F) { return doHoistPHIConstants(F); } - -    virtual void getAnalysisUsage(AnalysisUsage &AU) const { -      AU.preservesCFG(); -    } -  }; -} - -Pass *createHoistPHIConstantsPass() { return new HoistPHIConstants(); } | 

