[LLVMdev] llvm passes
Chris Lattner
sabre at nondot.org
Mon Sep 25 00:00:34 PDT 2006
On Fri, 22 Sep 2006, Ryan M. Lefever wrote:
> In the instructions for writing LLVM passes, it says "[c]urrently 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."
Right.
> I'm a little confused by that. It was my understanding that if pass X
> required pass Y, then pass Y would have to fully run and build up its
> internal data structures before pass X ran. Then, when pass X was run,
> X would call getAnalysis<Y> and get a reference to the pass Y object,
> which it could query for information stored during pass Y's execution.
> So, I'm wondering why the types of the passes matter. The statement
> that there would be "nowhere to store information for all of the
> functions in the program," confuses me.
Imagine you have a functionpass X, for example DominatorSet. DominatorSet
runs on a function at a time and captures information about the current
function's dominator information in its instance variables.
Now you have ModulePass Y that runs and requires X to be run. Because it
is a functionpass, X will be run on every function in the module before Y
starts. Further, because X only has one set of instance variables, Y
could see, at most, information for one function.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list