I am writing a ModulePass
and invoke it using opt -load
. I would require that alloca
has been promoted to registers when my pass runs, using the -mem2reg switch for opt.
There is a link which indicates that the PromoteMemoryToRegsiter pass is a transform pass and as such should not be required by my pass. That's a statement from 2010. Does that still hold?
One of the posts I found suggested something like
AU.addRequiredID(PromoteMemoryToRegister::MemoryToRegisterID);
but that contradicted the post I linked above.
So my question is, how to I express this dependency for my pass, if possible? How do I express, in general, such pass dependencies? And what's the difference between a transform pass and, well, another pass?
What's the difference between a transform pass and another pass?
A transform pass is a pass that may invalidate the results of other passes.
How to I express this dependency for my pass?
First of all, I recommend reading the pass-dependency section of the official "how to write a pass" guide. In any case, the correct way to add a dependency between transformation passes is to add one before the other in your pass manager (see the guide section on the pass manager), or, if you just invoke opt
, then add all the passes you want in the order you want them to occur, e.g.:
opt -load mypass.so -mem2reg -mypass