llvm 函数阅读笔记
PMTopLevelManager::schedulePass/// Schedule pass P for execution. Make sure that passes required by /// P are run before P is run. Update analysis info maintained by /// the manager. Remove dead passes. This is a recursive function. /*调度操作P。确保操作P所依赖的操作都已经执行完毕。更新分析信息*/ void PMTopLevelManager::schedulePass(Pass *P) { df df df d df df d // TODO : Allocate function manager for this pass, other wise required set /// may be inserted into previous function manager // Give pass a chance to prepare the stage. P->preparePassManager(activeStack); // If P is an analysis pass and it is available then do not // generate the analysis again. Stale analysis info should not be // available at this point. const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(P->getPassID()); if (PI && PI->isAnalysis() && findAnalysisPass(P->getPassID())) { delete P; return; } AnalysisUsage *AnUsage = findAnalysisUsage(P); bool checkAnalysis = true; while (checkAnalysis) { checkAnalysis = false; const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet(); for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(), E = RequiredSet.end(); I != E; ++I) { Pass *AnalysisPass = findAnalysisPass(*I); if (!AnalysisPass) { const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I); assert(PI && "Expected required passes to be initialized"); AnalysisPass = PI->createPass(); if (P->getPotentialPassManagerType () == AnalysisPass->getPotentialPassManagerType()) // Schedule analysis pass that is managed by the same pass manager. schedulePass(AnalysisPass); else if (P->getPotentialPassManagerType () > AnalysisPass->getPotentialPassManagerType()) { // Schedule analysis pass that is managed by a new manager. schedulePass(AnalysisPass); // Recheck analysis passes to ensure that required analyses that // are already checked are still available. checkAnalysis = true; } else // Do not schedule this analysis. Lower level analsyis // passes are run on the fly. delete AnalysisPass; } } } // Now all required passes are available. addTopLevelPass(P); }
posted @ 2011-09-13 20:50 luocean 阅读(31) 评论(0) 编辑

