// and elminate duplicates when it is initialized.
//
// The DynamicConstantMerge method is a superset of the ConstantMerge algorithm
-// that checks for each method to see if constants have been added to the
+// that checks for each function to see if constants have been added to the
// constant pool since it was last run... if so, it processes them.
//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/ConstantMerge.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/Pass.h"
// mergeDuplicateConstants - Workhorse for the pass. This eliminates duplicate
}
namespace {
- // FIXME: ConstantMerge should not be a methodPass!!!
- class ConstantMerge : public MethodPass {
+ // FIXME: ConstantMerge should not be a FunctionPass!!!
+ class ConstantMerge : public FunctionPass {
protected:
std::map<Constant*, GlobalVariable*> Constants;
unsigned LastConstantSeen;
return ::mergeDuplicateConstants(M, LastConstantSeen, Constants);
}
- bool runOnMethod(Method*) { return false; }
+ bool runOnFunction(Function *) { return false; }
// doFinalization - Clean up internal state for this module
//
Constants.clear();
return false;
}
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
};
struct DynamicConstantMerge : public ConstantMerge {
- // doPerMethodWork - Check to see if any globals have been added to the
+ // runOnFunction - Check to see if any globals have been added to the
// global list for the module. If so, eliminate them.
//
- bool runOnMethod(Method *M) {
- return ::mergeDuplicateConstants(M->getParent(), LastConstantSeen,
+ bool runOnFunction(Function *F) {
+ return ::mergeDuplicateConstants(F->getParent(), LastConstantSeen,
Constants);
}
};