LLVM Pass usable by all types of Passes

Hi

I am modifying LLVM to enable runtime feedback directed optimizations. I have modified the instrumentation part of LLVM to keep instrumentation data in some pre-setup structures in memory and use the JIT to recompile some of the hot functions with profiling information.

I need an analysis pass which loads the profiling data in memory and can be used by different optimization passes in LLVM, e.g. loopunroller, inliner, basicblockplacement, etc . Currently, I have an analysis pass that derives from a functionpass that loads the instrumentation data in memory and the basicblockplacement pass can then use that data as guide to place the blocks.

However, when i add the same pass as an analysis dependence to the loopunroller, i get some kind of infinite loop when the passes are scheduled here.

I would like to know is it allowed in LLVM to have a LoopPass depending on a FunctionPass ?

/// 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.
void PMTopLevelManager::schedulePass(Pass *P) {

else if (P->getPotentialPassManagerType () >
AnalysisPass->getPotentialPassManagerType()) {
*/// INFINITE LOOP HERE. maybe because checkAnalysis is set to true for some reasons not very clear based on the comments. *
printf(“Analysis Pass Name is %s\n”, AnalysisPass->getPassName());
// 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;
};

Thank you,
Trent