[LLVMdev] Optimization pass questions

Larry Gritz lg at larrygritz.com
Wed Aug 11 18:27:11 PDT 2010


On Aug 11, 2010, at 5:57 PM, Tanya Lattner wrote:

> Have you read this document?
> http://llvm.org/docs/WritingAnLLVMPass.html#passtype

Yes, but I didn't find it as instructive as I'd hoped.  The only two examples of pass sets I can find are the Kaleidoscope tutorial and StandardPasses.h (corresponding, I assume, to what llvm-gcc does).  Just looking at the two of these, some passes are done as function passes in one, but global passes in the other.  Is that generally ok?  I've experimented and some passes appear to work either way, others complain if you use it wrong.  I've found it hard to deduce, from just these examples and the docs, what the precise rules are, let alone best practices.


> It should explain what doInit and doFinalization means and when they are executed.. plus tons more good stuff.

Well just as an example, let's say you have a bunch of functions in a module, and you want to apply your function passes to each of them.

* Do you need to construct a separate FPM for each function, or can you construct it once and use it in succession for each function in the module?

* If the latter, do you doInitialization just once, then run() on each function, then doFinalization just once?  Or do you have to init/run/final separately for every function in the module?

I didn't find that WritingAnLLVMPass.html explicitly spelled out this kind of detail at all, though I I'm prepared to apologize profusely if I just missed it.

	-- lg

--
Larry Gritz
lg at larrygritz.com






More information about the llvm-dev mailing list