Problems understanding alias analysis validation logic

I have a problem where I add an Andersens AA pass to the pass manager, but it appears to get invalidated by another pass, and never rerun. My understanding from reading the documentation is that when a pass gets invalidated, it should be rerun before any other passes that requires it. Here is a simple example of the problem I am seeing:

PassManager passManager;
passManager.add(new TargetData(getTargetData()));
passManager.add(createGVNPass()); <----will use BasicAA not Andersens

In this case, I would expect that the GVN pass would use the andersen AA results, but it doesn't; it uses the results from a Basic AA pass. Reordering the passes like below fixes the problem, but I still don't understand why the andersens wasn't rerun before the GVN pass in the case above:

PassManager passManager;
passManager.add(new TargetData(*s_executionEngine->getTargetData()));
passManager.add(createGVNPass()); <----will correctly use the Andersens

I am using code from the trunk that is about 2 weeks old. Can anyone explain why the basicaa pass is used in the first case instead of the andersens, and what rule of thumb I need to follow to ensure that I get the AA pass I expect. Thanks,


Hi Damien,

I think the problem is that when the passmanager sees an Alias Analysis
available, it will use that, but when none is available, it will always run
the default implementation (BasicAA), regardless of any alias analysis's run
before. This means you should insert Andersen's before any pass that needs it.
I suspect (not sure though) that the passmanager will not rerun Andersen's if
it is still available, even when you explicitely add it.



I thought the pass manager was supposed to insulate you from the specifics of which passes invalidated which analysis passes.

It is possible to at least add the same analysis instance to avoid multiple allocations from the heap?


Simple answer, the pass manager is not smart enough. It does not remember that it invalidated one of the specialized analysis pass. It could be extended to handle this.