#include "llvm/Transforms/Scalar/PromoteMemoryToRegister.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/iMemory.h"
+#include "llvm/iPHINode.h"
+#include "llvm/iTerminators.h"
#include "llvm/Pass.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
-#include "llvm/Assembly/Writer.h" // For debugging
-#include "llvm/iPHINode.h"
-#include "llvm/iTerminators.h"
+#include "llvm/ConstantVals.h"
using namespace std;
-
-using cfg::DominanceFrontier;
-
namespace {
//instance of the promoter -- to keep all the local function data.
DominanceFrontier::DomSetType s = (*it).second;
for (DominanceFrontier::DomSetType::iterator p = s.begin();p!=s.end(); ++p)
{
- if (queuePhiNode((BasicBlock *)*p, i))
- PhiNodes[i].push_back((BasicBlock *)*p);
+ if (queuePhiNode(*p, i))
+ PhiNodes[i].push_back(*p);
}
}
// perform iterative step
DominanceFrontier::DomSetType s = it->second;
for (DominanceFrontier::DomSetType::iterator p = s.begin(); p!=s.end(); ++p)
{
- if (queuePhiNode((BasicBlock *)*p,i))
- PhiNodes[i].push_back((BasicBlock*)*p);
+ if (queuePhiNode(*p,i))
+ PhiNodes[i].push_back(*p);
}
}
}
namespace {
- struct PromotePass : public MethodPass {
+ struct PromotePass : public FunctionPass {
- // runOnMethod - To run this pass, first we calculate the alloca
+ // runOnFunction - To run this pass, first we calculate the alloca
// instructions that are safe for promotion, then we promote each one.
//
- virtual bool runOnMethod(Function *F) {
+ virtual bool runOnFunction(Function *F) {
return (bool)PromoteInstance(F, getAnalysis<DominanceFrontier>());
}
- // getAnalysisUsageInfo - We need dominance frontiers
+ // getAnalysisUsage - We need dominance frontiers
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
- Requires.push_back(DominanceFrontier::ID);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired(DominanceFrontier::ID);
}
};
}