forked from OSchip/llvm-project
LPPassManager. Implement preparePassManager() hook.
llvm-svn: 34975
This commit is contained in:
parent
9d9fc90952
commit
1699384509
|
@ -45,6 +45,14 @@ class LoopPass : public Pass {
|
||||||
// loop nest is completely different.
|
// loop nest is completely different.
|
||||||
virtual bool doFinalization() { return false; }
|
virtual bool doFinalization() { return false; }
|
||||||
|
|
||||||
|
// Check if this pass is suitable for the current LPPassManager, if
|
||||||
|
// available. This pass P is not suitable for a LPPassManager if P
|
||||||
|
// is not preserving higher level analysis info used by other
|
||||||
|
// LPPassManager passes. In such case, pop LPPassManager from the
|
||||||
|
// stack. This will force assignPassManager() to create new
|
||||||
|
// LPPassManger as expected.
|
||||||
|
void preparePassManager(PMStack &PMS);
|
||||||
|
|
||||||
/// Assign pass manager to manager this pass
|
/// Assign pass manager to manager this pass
|
||||||
virtual void assignPassManager(PMStack &PMS,
|
virtual void assignPassManager(PMStack &PMS,
|
||||||
PassManagerType PMT = PMT_LoopPassManager);
|
PassManagerType PMT = PMT_LoopPassManager);
|
||||||
|
|
|
@ -129,6 +129,31 @@ bool LPPassManager::runOnFunction(Function &F) {
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// LoopPass
|
// LoopPass
|
||||||
|
|
||||||
|
// Check if this pass is suitable for the current LPPassManager, if
|
||||||
|
// available. This pass P is not suitable for a LPPassManager if P
|
||||||
|
// is not preserving higher level analysis info used by other
|
||||||
|
// LPPassManager passes. In such case, pop LPPassManager from the
|
||||||
|
// stack. This will force assignPassManager() to create new
|
||||||
|
// LPPassManger as expected.
|
||||||
|
void LoopPass::preparePassManager(PMStack &PMS) {
|
||||||
|
|
||||||
|
// Find LPPassManager
|
||||||
|
while (!PMS.empty()) {
|
||||||
|
if (PMS.top()->getPassManagerType() > PMT_LoopPassManager)
|
||||||
|
PMS.pop();
|
||||||
|
else;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPPassManager *LPPM = dynamic_cast<LPPassManager *>(PMS.top());
|
||||||
|
|
||||||
|
// If this pass is destroying high level information that is used
|
||||||
|
// by other passes that are managed by LPM then do not insert
|
||||||
|
// this pass in current LPM. Use new LPPassManager.
|
||||||
|
if (LPPM && !LPPM->preserveHigherLevelAnalysis(this))
|
||||||
|
PMS.pop();
|
||||||
|
}
|
||||||
|
|
||||||
/// Assign pass manager to manage this pass.
|
/// Assign pass manager to manage this pass.
|
||||||
void LoopPass::assignPassManager(PMStack &PMS,
|
void LoopPass::assignPassManager(PMStack &PMS,
|
||||||
PassManagerType PreferredType) {
|
PassManagerType PreferredType) {
|
||||||
|
|
Loading…
Reference in New Issue