[LLVMdev] Function Pass Manager
Ivan Llopard
ivanllopard at gmail.com
Thu Apr 12 01:32:29 PDT 2012
Hi again,
I come back to this issue with an example. It's a pass which does
nothing but throw the 'Unable to schedule' error.
namespace {
struct MyPass : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
MyPass() : FunctionPass(ID) {
initializeMyPassPass(*PassRegistry::getPassRegistry());
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(LoopSimplifyID);
AU.addPreservedID(LoopSimplifyID);
}
virtual bool runOnFunction(Function &F);
};
}
char MyPass::ID = 0;
INITIALIZE_PASS_BEGIN(MyPass, "mypass", "mypass",
false, false)
INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
INITIALIZE_PASS_END(MyPass, "mypass", "mypass",
false, false)
bool MyPass::runOnFunction(Function &F) {
return MyPass::ID == 0;
}
FunctionPass *llvm::createMyPassPass() {
return new MyPass();
}
It's a simple FunctionPass requiring a lower level pass, LoopSimplify. I
wrote this pass among the other llvm passes in Transform/Scalar, it's
not a dynamic loaded pass.
It's worth to note that if I change this pass to be a ModulePass
instead, the required pass LoopSimplify is scheduled on-the-fly without
problems.
Is there any reason to not specialize addLowerLevelRequiredPass() for
function managers ?
Ivan
Le 23/03/2012 17:00, Ivan Llopard a écrit :
> Hi,
>
> I'm writing a function pass which is dynamically loaded by opt and I
> need some analysis and passes to be run before my pass:
>
> virtual void getAnalysisUsage(AnalysisUsage &AU) const {
> AU.addRequired<LoopInfo>();
> AU.addPreserved<LoopInfo>();
> AU.addRequiredID(LoopSimplifyID);
> AU.addPreservedID(LoopSimplifyID);
> AU.addRequiredID(LCSSAID);
> AU.addPreservedID(LCSSAID);
> AU.addRequired<ScalarEvolution>();
> AU.addPreserved<ScalarEvolution>();
> }
>
> When I run it with opt -load, I'm getting the following error:
>
> Unable to schedule 'Canonicalize natural loops' required by 'MyPass'
> Unable to schedule pass
>
> After looking at the pass manager framework, it seems that passes with
> lower level than FunctionPass (such as LoopPass in my particular case)
> cannot be scheduled on-the-fly or must be handled by specific function
> managers. This is not the case for module passes, i.e. module passes
> requiring function ones. Is it correct ?
>
> In other words, why is addLowerLevelRequiredPass() not specialized for
> function managers ?
>
> I think I'm misunderstanding the whole thing, is it possible to chain
> transformation passes from my pass or do I chain them explicitly from
> the command line ?
>
> Thanks in advance,
>
> Ivan
More information about the llvm-dev
mailing list