#include "llvm/Analysis/Dominators.h"
#include "llvm-c/Core.h"
#include <algorithm>
+#include <cstdio>
#include <vector>
#include <map>
using namespace llvm;
public:
static char ID;
explicit BBPassManager(int Depth)
- : PMDataManager(Depth), FunctionPass((intptr_t)&ID) {}
+ : PMDataManager(Depth), FunctionPass(&ID) {}
/// Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the function, and if so, return true.
public:
static char ID;
explicit FunctionPassManagerImpl(int Depth) :
- Pass((intptr_t)&ID), PMDataManager(Depth),
+ Pass(&ID), PMDataManager(Depth),
PMTopLevelManager(TLM_Function) { }
/// add - Add a pass to the queue of passes to run. This passes ownership of
public:
static char ID;
explicit MPPassManager(int Depth) :
- Pass((intptr_t)&ID), PMDataManager(Depth) { }
+ Pass(&ID), PMDataManager(Depth) { }
// Delete on the fly managers.
virtual ~MPPassManager() {
public:
static char ID;
explicit PassManagerImpl(int Depth) :
- Pass((intptr_t)&ID), PMDataManager(Depth),
- PMTopLevelManager(TLM_Pass) { }
+ Pass(&ID), PMDataManager(Depth), PMTopLevelManager(TLM_Pass) { }
/// add - Add a pass to the queue of passes to run. This passes ownership of
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
if (TheTimeInfo) TheTimeInfo->passStarted(*I);
(*I)->releaseMemory();
if (TheTimeInfo) TheTimeInfo->passEnded(*I);
-
- std::map<AnalysisID, Pass*>::iterator Pos =
- AvailableAnalysis.find((*I)->getPassInfo());
-
- // It is possible that pass is already removed from the AvailableAnalysis
- if (Pos != AvailableAnalysis.end())
- AvailableAnalysis.erase(Pos);
+ if (const PassInfo *PI = (*I)->getPassInfo()) {
+ std::map<AnalysisID, Pass*>::iterator Pos =
+ AvailableAnalysis.find(PI);
+
+ // It is possible that pass is already removed from the AvailableAnalysis
+ if (Pos != AvailableAnalysis.end())
+ AvailableAnalysis.erase(Pos);
+
+ // Remove all interfaces this pass implements, for which it is also
+ // listed as the available implementation.
+ const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
+ for (unsigned i = 0, e = II.size(); i != e; ++i) {
+ Pos = AvailableAnalysis.find(II[i]);
+ if (Pos != AvailableAnalysis.end() && Pos->second == *I)
+ AvailableAnalysis.erase(Pos);
+ }
+ }
}
}
else
break;
}
-
+ assert(!PMS.empty() && "Unable to find appropriate Pass Manager");
PMS.top()->add(this);
}
void FunctionPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
- // Find Module Pass Manager (TODO : Or Call Graph Pass Manager)
+ // Find Module Pass Manager
while(!PMS.empty()) {
if (PMS.top()->getPassManagerType() > PMT_FunctionPassManager)
PMS.pop();
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
-
- // If Call Graph Pass Manager is active then use it to manage
- // this new Function Pass manager.
- if (PMD->getPassManagerType() == PMT_CallGraphPassManager)
- FPP->assignPassManager(PMS, PMT_CallGraphPassManager);
- else
- FPP->assignPassManager(PMS);
+ FPP->assignPassManager(PMS, PMD->getPassManagerType());
// [4] Push new manager into PMS
PMS.push(FPP);