[LLVMdev] The "scope" of passes

ether zhhb etherzhhb at gmail.com
Mon Apr 12 18:41:50 PDT 2010


hi again :)

On Tue, Apr 13, 2010 at 8:57 AM, ether zhhb <etherzhhb at gmail.com> wrote:

> hi john,
>
> thanks very much, i will try it out.
>
> --best regards
> ether
>
>
> On Mon, Apr 12, 2010 at 10:03 PM, John Criswell <criswell at uiuc.edu> wrote:
>
>> 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.
>>
> that's because FunctionPass implement the "addLowerLevelRequiredPass"
function, but others not.

so, is there any special reason that only "addLowerLevelRequiredPass" is
allow?


>
>> -- John T.
>
>
--best regards
ether
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100413/bdd7ae97/attachment.html>


More information about the llvm-dev mailing list