[LLVMdev] Pass vs. FunctionPass
Patrick Meredith
pmeredit at uiuc.edu
Thu Jun 24 09:16:01 PDT 2004
----- Original Message -----
From: "Vladimir Prus" <ghost at cs.msu.su>
To: <llvmdev at cs.uiuc.edu>
Sent: Thursday, June 24, 2004 8:37 AM
Subject: [LLVMdev] Pass vs. FunctionPass
>
> I wonder in what cases FunctionPass is better that Pass. For example,
> addPassesToEmitAssembly takes PassManger and addPassesToJITCompile takes
> FunctionPassManager.
It's just better from a software engineering perspective to use FunctionPass
if you are doing things on the global (function) level rather than the
module level. Also it allows passes to be scheduled in order on functions
rather than whole modules.
> Another question is about FunctionPassManager::run(Function&) and
> FunctionPass(Function&). The former calls the later, which is fine, but
the
> latter looks like this:
>
> bool FunctionPass::run(Function &F) {
> if (F.isExternal()) return false;// Passes are not run on external
> functions!
>
> return doInitialization(*F.getParent()) | runOnFunction(F)
> | doFinalization(*F.getParent());
> }
>
> So, with FunctionPassManager, doInitializaton will be called once for each
> function, which is strange, given that that method takes Module&. When
this
> behaviour is desirable?
I never looked at this code before. That explains why I've had issues with
doFinalization before, because I always assumed it only ran once per module
myself. It seems undesirable to me because not only is this a little
counter intuitive, but it also repeats work that need only be done once.
But maybe there is a good reason for this?
> - Volodya
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list