[llvm-dev] Out-of-tree AA pass used from ModulePass

Stephan Diestelhorst via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 16 09:35:19 PDT 2021


(Please keep me in CC, not sure my subscription request has made it through yet)
Hi all,

I am building a fairly extensive set of compiler passes out-of-tree with LLVM, and this all works nicely, except for tying my custom AA pass MyAA into the overall AA aggregator via AAResultsWrapper. As far as I can see, the ExternalAAWrapper does what I want and allows me to add an out-of-tree AA pass to the list of passes that is consulted when my other passes (let's say MyFuncPass) need an alias analysis result, by having registered a call-back in ExternalAAWrapper that will add MyAAResult into llvm::AAResult, which then gets consulted in AA queries if needed. This works for now (with some hacks).

The problem is, however, when I convert MyFuncPass to a module pass, and I am then trying to get aa results for my functions.  The problem is that the call-back I registered (I see that happening!) with ExternalAAWrapper is never being run, so my AA results are not added to the mix.  I am using opt and the legacy pass managers, and I am struggling to understand how this should be used correctly, and why the call-back is not executed in time when turning my pass into a ModulePass.

I am getting my aa results via getAnalysis<AAResultsWrapperPass>().getAAResults() in MyFuncPass, and with getAnalysis<AAResultsWrapperPass>(f).getAAResults() with f being the function I am currently looking into in the ModulePass.

I am not really sure which passes I must specify with addRequired(..) or on the command line and it seems the documentation around AA in general and external AA specifically is somewhat outdated / sparse.

Does this fairly high-level description ring any bells?  My code is pretty wild at this point, so it is not trivial to create a simple example, but I can do it if it would be helpful here.  Further, for various reasons (started this project a fair while ago) I am still on LLVM 8, but AFAICS, not much has changed in this area. That said, I don't have a great understanding how the whole (legacy) pass manager piece hangs together.

Thanks,
  Stephan
--
Stephan Diestelhorst
System Architect
Xilinx - Data Center Group
Cambridge, UK

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.


More information about the llvm-dev mailing list