[LLVMdev] The "scope" of passes
criswell at uiuc.edu
Tue Apr 13 07:38:47 PDT 2010
Devang Patel wrote:
> On Mon, Apr 12, 2010 at 6:41 PM, ether zhhb <etherzhhb at gmail.com> wrote:
>> that's because FunctionPass implement the "addLowerLevelRequiredPass"
>> function, but others not.
>> so, is there any special reason that only "addLowerLevelRequiredPass" is
> There is no reason to not allow it. It is not done because there was
> not any use. If you need this then pl. prepare a patch!
Alternatively, if you wrote the BasicBlock analysis pass, you could
easily modify it to be a FunctionPass.
Currently, I think this is a better alternative because:
1) It doesn't require patching LLVM (meaning that your passes can work
with LLVM 2.7)
2) You will get better reusability of the analysis results. When a
higher level pass calls a lower level pass (e.g., ModulePass calls
FunctionPass), the lower level pass is run again, even if it was run
previously and did not have its analysis results invalidated. If the
passes are of the same level (e.g., FunctionPass requires FunctionPass),
then the PassManager can avoid duplicate runs of the analysis pass if
its results are not invalidated.
-- John T.
More information about the llvm-dev