Julien Schmitt wrote:
Well, now i added the creation of my AA just before the
creation of DSE, (in the former case it was done at top of all passes list)
and it's working (alias and getModRefInfo are called)...
Maybe a particular pass destroyed the AliasAnalysGroup ??
Yes, this is a known limitation of the PassManager. The PassManager will try to automatically schedule analysis passes for registered transform passes as needed. However, when scheduling an analysis group, it will always pick the default implementation (in the case of AliasAnalysis, it's BasicAA) if there is not another implementation that has been explicitly added *and* not invalidated by a subsequent transform.
As an example, let us say that your AliasAnalysis pass is called A, a pass B uses the AliasAnalysis group, and a pass C invalidates all analysis passes. If you explicitly tell PassManager to run, in the following order:
... then your pass A will be run, followed by B which will use it as expected. Pass C will invalidate A, and then PassManager will need to schedule another AliasAnalysis group pass between C and the second execution of B since B needs AliasAnalysis results. Currently, PassManager will run BasicAA because it selects the default. So, what you get in the end is:
The solution for now is to simply know which passes will require an AliasAnalysis group and to ensure that your pass is always available when such passes are run. This requires you to explicitly schedule your alias analysis pass before any transform that needs alias analysis.
Note that you'll get this behavior whether you use opt or you build your own command-line tool that uses PassManager. Both use PassManager to schedule passes.
However he solution is not very clean, since i don't know which
pass need an AA (i guess this should be automatic whith the
method 'getAnalysisUsage' )
Agreed. It would be better if you could tell PassManager something to the effect of:
"when a pass requests an analysis of this group, run this subset of passes from that group and let them be queried in this order."
However, to the best of my knowledge, no one has implemented such a feature (or one like it) yet.
-- John T.