[LLVMdev] The "scope" of passes

John Criswell criswell at uiuc.edu
Mon Apr 12 07:03:51 PDT 2010

ether zhhb wrote:
> hi all,
> i have some thing not so sure about "scope" of llvm passes:
> suppose i have a function pass PassF and a BasicBlock analysis pass 
> PassB. if i want to use the analysis result of PassB for a BasicBlock 
> in PassF, i think i can create PassB in runOnFunction of PassF, and 
> call runOnBasicBlock manually to get the result:
> PassB pb; //create a PassB
> //we also need consider the analysis usage of PassB
> pb.runOnBasicBlock(bb); // run PassB on bb manually
> .... use the result of pb ......
> is there any other better way?

I think the correct way to do this is to declare PassB as a prerequisite 
pass in PassF's getAnalysisUsage() method and then to use 
getAnalysis<PassB>(BasicBlock * BB) in PassF.

A ModulePass can use a FunctionPass, so I assume a FunctionPass can use 
a BasicBlockPass in this fashion.

-- John T.

> thanks very much
> --ether

More information about the llvm-dev mailing list