/// Initialize available analysis information.
void initializeAnalysisInfo() {
- TransferLastUses.clear();
AvailableAnalysis.clear();
}
void dumpAnalysisSetInfo(const char *Msg, Pass *P,
const std::vector<AnalysisID> &Set) const;
- std::vector<Pass *>& getTransferredLastUses() {
- return TransferLastUses;
- }
-
virtual unsigned getNumContainedPasses() {
return PassVector.size();
}
}
protected:
- // If a FunctionPass F is the last user of ModulePass info M
- // then the F's manager, not F, records itself as a last user of M.
- // Current pass manage is requesting parent manager to record parent
- // manager as the last user of these TrransferLastUses passes.
- std::vector<Pass *> TransferLastUses;
-
// Top level manager.
PMTopLevelManager *TPM;
recordAvailableAnalysis(IP);
} else {
P->assignPassManager(activeStack);
- activeStack.handleLastUserOverflow();
}
}
recordAvailableAnalysis(IP);
} else {
P->assignPassManager(activeStack);
- activeStack.handleLastUserOverflow();
}
}
AnalysisResolver *AR = new AnalysisResolver(*this);
P->setResolver(AR);
+ // If a FunctionPass F is the last user of ModulePass info M
+ // then the F's manager, not F, records itself as a last user of M.
+ std::vector<Pass *> TransferLastUses;
+
if (ProcessAnalysis) {
// At the moment, this pass is the last user of all required passes.
LastUses.push_back(P);
TPM->setLastUser(LastUses, P);
+ if (!TransferLastUses.empty()) {
+ Pass *My_PM = dynamic_cast<Pass *>(this);
+ TPM->setLastUser(TransferLastUses, My_PM);
+ TransferLastUses.clear();
+ }
+
// Take a note of analysis required and made available by this pass.
// Remove the analysis not preserved by this pass
removeNotPreservedAnalysis(P);
printf ("\n");
}
-// Walk Pass Manager stack and set LastUse markers if any
-// manager is transfering this priviledge to its parent manager
-void PMStack::handleLastUserOverflow() {
-
- for(PMStack::iterator I = this->begin(), E = this->end(); I != E;) {
-
- PMDataManager *Child = *I++;
- if (I != E) {
- PMDataManager *Parent = *I++;
- PMTopLevelManager *TPM = Parent->getTopLevelManager();
- std::vector<Pass *> &TLU = Child->getTransferredLastUses();
- if (!TLU.empty()) {
- Pass *P = dynamic_cast<Pass *>(Parent);
- TPM->setLastUser(TLU, P);
- TLU.clear();
- }
- }
- }
-}
-
/// Find appropriate Module Pass Manager in the PM Stack and
/// add self into that manager.
void ModulePass::assignPassManager(PMStack &PMS,