[LLVMdev] ModulePasses requiring FunctionPasses
pmeredit at uiuc.edu
Mon May 1 12:48:24 PDT 2006
On May 1, 2006, at 1:00 PM, Balpreet Pankaj wrote:
> I am trying to write a ModulePass which requires PostDominator sets
> for every function in the module. Now finding post dominators is a
> function pass. The link on the llvm.org website says that :
> "Currently it is illegal for a ModulePass to require a
> FunctionPass. This is because there is only one instance of the
> FunctionPass object ever created, thus nowhere to store information
> for all of the functions in the program at the same time. Although
> this has come up a couple of times before, this has always been
> worked around by factoring one big complicated pass into a global
> and an interprocedural part, both of which are distinct. In the
> future, it would be nice to have this though."
> This says that we can work around by factoring the code into a
> global and interprocedural part. If so, is our global pass a Module
> pass ? And then, how do the global and inter-procedural passes
> interact ? Is there a specific example where this has been done
> before ?
Ahhh, you must remember the terribly confusing terminology. Global
means function level. This is sort of like doing an iterative data
you have a part that computes local basic block analyses, and then
the global part merges those analyses at exits and entries to
you are going to do something on a function level, store it to data
structures of some sort and use a ModulePass to merge at calls. The
problem I see is this is still an issue of a Module Pass Requiring a
FunctionPass, so you are going to have to declare some sort of structure
like a std::vector of whatever analysis structure you need, and "push
a new one on" in the beginning of run on Function. A hash_map
from Function* to analysis information might be better however.
Actually, if you want to get this working really fast it might be better
to just edit PostDominator set to have a map of PostDominatorSets,
and make it a ModulePass.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev