[LLVMdev] How to visualise Clang optimisation phases

Edmund Grimley-Evans Edmund.Grimley-Evans at arm.com
Fri Jul 16 03:24:33 PDT 2010


When I'm trying to understand how or why the back end does something
I've found the -view-* options to llc to be useful. It's not ideal,
because "clang" doesn't take those options, so I have to invoke first
"clang" and then "llc", and sometimes that combination gives different
final code from invoking just "clang", but usually I can construct a
simple example in which "clang" and "clang | llc" give the same output
and then use -view-legalize-dags, etc with "llc".

However, when I'm trying to understand an optimisation that happens
(or doesn't happen) earlier on in the compiler I've found this
approach sometimes doesn't work at all. If I invoke "clang" with no
optimisation options then the optimisation I'm interested in has
already happened before the bitcode is generated, but if I invoke
"clang" with -O0 then "llc" doesn't do it either and the optimisation
doesn't happen at all.

Is there a way of tracing what "clang" actually does and extracting
the intermediate representation between the phases?

Or is this a question for cfe-dev?

(I'm currently trying to understand how some conditional expressions
are optimised.)

Thanks for any advice.



-- 
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.




More information about the llvm-dev mailing list