using cfg::DominanceFrontier;
+namespace {
//instance of the promoter -- to keep all the local method data.
// gets re-created for each method processed
operator bool () { return didchange; }
};
-class PromotePass : public MethodPass {
- public:
-
- // runOnMethod - To run this pass, first we calculate the alloca instructions
- // that are safe for promotion, then we promote each one.
- //
- virtual bool runOnMethod(Method *M)
- {
- PromoteInstance inst(M, getAnalysis<DominanceFrontier>());
- return (bool)inst;
- }
-
-
- // getAnalysisUsageInfo - We need dominance frontiers
- //
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
- Requires.push_back(DominanceFrontier::ID);
- }
-};
-
+} // end of anonymous namespace
// findSafeAllocas - Find allocas that are safe to promote
//
-// newPromoteMemoryToRegister - Provide an entry point to create this pass.
-//
-Pass *newPromoteMemoryToRegister() {
- return new PromotePass();
-}
-
-
bool PromoteInstance::PromoteMethod(Method *M, DominanceFrontier & DF) {
// Calculate the set of safe allocas
findSafeAllocas(M);
}
return false;
}
+
+
+namespace {
+ class PromotePass : public MethodPass {
+ public:
+
+ // runOnMethod - To run this pass, first we calculate the alloca
+ // instructions that are safe for promotion, then we promote each one.
+ //
+ virtual bool runOnMethod(Method *M)
+ {
+ PromoteInstance inst(M, getAnalysis<DominanceFrontier>());
+ return (bool)inst;
+ }
+
+
+ // getAnalysisUsageInfo - We need dominance frontiers
+ //
+ virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
+ Pass::AnalysisSet &Destroyed,
+ Pass::AnalysisSet &Provided) {
+ Requires.push_back(DominanceFrontier::ID);
+ }
+ };
+}
+
+
+// createPromoteMemoryToRegister - Provide an entry point to create this pass.
+//
+Pass *createPromoteMemoryToRegister() {
+ return new PromotePass();
+}
+
+