#include "llvm/PassManager.h"
#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
+#include "llvm/BasicBlock.h"
#include "Support/STLExtras.h"
#include <algorithm>
// debugging on, a command line option (--debug-pass) is enabled that causes the
// pass name to be printed before it executes.
//
-#ifndef NDEBUG
#include "Support/CommandLine.h"
#include <typeinfo>
#include <iostream>
void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
Pass *P, Value *V) {
if (PassDebugging >= PassExecutions) {
- std::cerr << std::string(Depth*2, ' ') << Action << " '"
+ std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '"
<< typeid(*P).name();
if (V) {
std::cerr << "' on ";
switch (V->getValueType()) {
case Value::ModuleVal:
std::cerr << "Module\n"; return;
- case Value::MethodVal:
- std::cerr << "Method '" << V->getName(); break;
+ case Value::FunctionVal:
+ std::cerr << "Function '" << V->getName(); break;
case Value::BasicBlockVal:
std::cerr << "BasicBlock '" << V->getName(); break;
default:
}
void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg,
- const Pass::AnalysisSet &Set) {
+ Pass *P, const Pass::AnalysisSet &Set) {
if (PassDebugging >= PassDetails && !Set.empty()) {
- std::cerr << std::string(Depth*2+2, ' ') << Msg << " Analyses:";
+ std::cerr << (void*)P << std::string(Depth*2+3, ' ') << Msg << " Analyses:";
for (unsigned i = 0; i < Set.size(); ++i) {
Pass *P = Set[i].createPass(); // Good thing this is just debug code...
std::cerr << " " << typeid(*P).name();
void Pass::dumpPassStructure(unsigned Offset = 0) {
std::cerr << std::string(Offset*2, ' ') << typeid(*this).name() << "\n";
}
-#endif
//===----------------------------------------------------------------------===//
// Pass Implementation
//
-void Pass::addToPassManager(PassManagerT<Module> *PM, AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- PM->addPass(this, Destroyed, Provided);
+void Pass::addToPassManager(PassManagerT<Module> *PM, AnalysisSet &Required,
+ AnalysisSet &Destroyed, AnalysisSet &Provided) {
+ PM->addPass(this, Required, Destroyed, Provided);
}
//===----------------------------------------------------------------------===//
// run - On a method, we simply initialize, run the method, then finalize.
//
-bool MethodPass::run(Method *M) {
- if (M->isExternal()) return false; // Passes are not run on external methods!
+bool MethodPass::run(Function *F) {
+ if (F->isExternal()) return false; // Passes are not run on external methods!
- return doInitialization(M->getParent()) | runOnMethod(M)
- | doFinalization(M->getParent());
+ return doInitialization(F->getParent()) | runOnMethod(F)
+ | doFinalization(F->getParent());
}
void MethodPass::addToPassManager(PassManagerT<Module> *PM,
- AnalysisSet &Destroyed,
+ AnalysisSet &Required, AnalysisSet &Destroyed,
AnalysisSet &Provided) {
- PM->addPass(this, Destroyed, Provided);
+ PM->addPass(this, Required, Destroyed, Provided);
}
-void MethodPass::addToPassManager(PassManagerT<Method> *PM,
- AnalysisSet &Destroyed,
+void MethodPass::addToPassManager(PassManagerT<Function> *PM,
+ AnalysisSet &Required, AnalysisSet &Destroyed,
AnalysisSet &Provided) {
- PM->addPass(this, Destroyed, Provided);
+ PM->addPass(this, Required, Destroyed, Provided);
}
//===----------------------------------------------------------------------===//
// To run this pass on a method, we simply call runOnBasicBlock once for each
// method.
//
-bool BasicBlockPass::runOnMethod(Method *M) {
+bool BasicBlockPass::runOnMethod(Function *F) {
bool Changed = false;
- for (Method::iterator I = M->begin(), E = M->end(); I != E; ++I)
+ for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
Changed |= runOnBasicBlock(*I);
return Changed;
}
return doInitialization(M) | runOnBasicBlock(BB) | doFinalization(M);
}
-void BasicBlockPass::addToPassManager(PassManagerT<Method> *PM,
+void BasicBlockPass::addToPassManager(PassManagerT<Function> *PM,
+ AnalysisSet &Required,
AnalysisSet &Destroyed,
AnalysisSet &Provided) {
- PM->addPass(this, Destroyed, Provided);
+ PM->addPass(this, Required, Destroyed, Provided);
}
void BasicBlockPass::addToPassManager(PassManagerT<BasicBlock> *PM,
+ AnalysisSet &Required,
AnalysisSet &Destroyed,
AnalysisSet &Provided) {
- PM->addPass(this, Destroyed, Provided);
+ PM->addPass(this, Required, Destroyed, Provided);
}