Reproducing Clang behavior using opt

Hi all,

We've a problem in AddressSanitizer
(http://code.google.com/p/address-sanitizer/issues/detail?id=61) that
is probably related to the order in which Clang executes the
optimization passes.
Namely, the ASan pass jumps in too early and prevents a bunch of
memory accesses from being moved to the registers.

I wonder if it's possible to reconstruct Clang's compilation pipeline
using opt, i.e. dump the bitcode, obtain the list of passes being ran
and run them one by one on the target file.
This will perhaps help to pinpoint the problem, because otherwise I'll
need to try Clang extension points, which may take some time (and may
be insufficient).

Try ‘-mllvm -debug-pass=Arguments’ – it should help you understand what passes Clang is running.

You should also look at ‘opt -help-hidden’. There are a ton of debugging and printing options, many of which can be passed through a Clang compilation using ‘-mllvm’.