[LLVMdev] Default Alias analysis passes for PassManager

Max Bolingbroke batterseapower at hotmail.com
Thu Sep 29 07:33:09 PDT 2011


Hi,

I'm writing a custom alias analyser for the Glasgow Haskell Compiler's
LLVM backend to teach LLVM that our explicitly-represented stack
cannot alias with any heap pointer.

It works, but I've hit an issue with opt's handling of alias
analysers; if you specify -ghc-aa on the opt command line then LLVM
only uses that analyser until (I think) a pass runs that invalidates
the results of alias analysis. My workaround was to:
  1. Use "opt -O2 -debug-pass=Structure" to get the list of flags
equivalent to using -O2
  2. Insert -ghc-aa between each flag, to force them to use my alias analyser
  3. Use "opt ... huge-list-of-flags ..." to actually do the optimisation

This produces quite nice code! But what I really want to do is say
something like "opt -ghc-aa -O2" and not hard-code this huge flag list
in my user of opt.

I see this issue with opt has been discussed before
(http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-November/036500.html)
but there was no real conclusion on a nicer way to do this. So my
questions are:

 1. Has/will PassManager be changed to allow a default alias analyser
stack to be set somehow?
 2. If I insert -ghc-aa between each pass, will LLVM only use the
results of my analyser, or will it chain it with -basic-aa? (Perhaps I
should say "-basic-aa -ghc-aa" instead?) The output of
-debug-pass=Structure is not very clear on which alias analyser
applies where.

Max



More information about the llvm-dev mailing list