PMT_CallGraphPassManager, /// CGPassManager
PMT_FunctionPassManager, /// FPPassManager
PMT_LoopPassManager, /// LPPassManager
- PMT_BasicBlockPassManager /// BBPassManager
+ PMT_BasicBlockPassManager, /// BBPassManager
+ PMT_Last
};
typedef enum PassManagerType PassManagerType;
/// used by pass managers.
class PMDataManager {
public:
+
PMDataManager(int Depth) : TPM(NULL), Depth(Depth) {
initializeAnalysisInfo();
}
/// Initialize available analysis information.
void initializeAnalysisInfo() {
AvailableAnalysis.clear();
+ for (unsigned i = 0; i < PMT_Last; ++i)
+ InheritedAnalysis[i] = NULL;
}
/// Populate RequiredPasses with the analysis pass that are required by
assert ( 0 && "Invalid use of getPassManagerType");
return PMT_Unknown;
}
+
+ std::map<AnalysisID, Pass*> *getAvailableAnalysis() {
+ return &AvailableAnalysis;
+ }
+
+ // Collect AvailableAnalysis from all the active Pass Managers.
+ void populateInheritedAnalysis(PMStack &PMS) {
+ unsigned Index = 0;
+ for (PMStack::iterator I = PMS.begin(), E = PMS.end();
+ I != E; ++I)
+ InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis();
+ }
+
protected:
// Top level manager.
// Collection of pass that are managed by this manager
std::vector<Pass *> PassVector;
+ // Collection of Analysis provided by Parent pass manager and
+ // used by current pass manager. At at time there can not be more
+ // then PMT_Last active pass mangers.
+ std::map<AnalysisID, Pass *> *InheritedAnalysis[PMT_Last];
+
private:
// Set of available Analysis. This information is used while scheduling
// pass. If a pass requires an analysis which is not not available then
AvailableAnalysis.erase(Info);
}
}
+
+ // Check inherited analysis also. If P is not preserving analysis
+ // provided by parent manager then remove it here.
+ for (unsigned Index = 0; Index < PMT_Last; ++Index) {
+
+ if (!InheritedAnalysis[Index])
+ continue;
+
+ for (std::map<AnalysisID, Pass*>::iterator
+ I = InheritedAnalysis[Index]->begin(),
+ E = InheritedAnalysis[Index]->end(); I != E; ) {
+ std::map<AnalysisID, Pass *>::iterator Info = I++;
+ if (std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
+ PreservedSet.end()) {
+ // Remove this analysis
+ if (!dynamic_cast<ImmutablePass*>(Info->second))
+ InheritedAnalysis[Index]->erase(Info);
+ }
+ }
+ }
+
}
/// Remove analysis passes that are not used any longer