Keep track of inherited analysis. For example, if a loop pass does not

preserve dominator info then it should update parent FPPassManager's
available analysis info to reflect this.

llvm-svn: 34942
This commit is contained in:
Devang Patel 2007-03-06 01:55:46 +00:00
parent edbde240be
commit 45343b04b3
3 changed files with 44 additions and 1 deletions

View File

@ -64,7 +64,8 @@ enum PassManagerType {
PMT_CallGraphPassManager, /// CGPassManager
PMT_FunctionPassManager, /// FPPassManager
PMT_LoopPassManager, /// LPPassManager
PMT_BasicBlockPassManager /// BBPassManager
PMT_BasicBlockPassManager, /// BBPassManager
PMT_Last
};
typedef enum PassManagerType PassManagerType;

View File

@ -197,6 +197,7 @@ private:
/// used by pass managers.
class PMDataManager {
public:
PMDataManager(int Depth) : TPM(NULL), Depth(Depth) {
initializeAnalysisInfo();
}
@ -223,6 +224,8 @@ public:
/// 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
@ -262,6 +265,19 @@ public:
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.
@ -270,6 +286,11 @@ protected:
// 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

View File

@ -551,6 +551,27 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
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