[cfe-dev] clang questions

Eli Friedman eli.friedman at gmail.com
Fri Mar 16 15:07:30 PDT 2012


On Fri, Mar 16, 2012 at 2:53 PM, Jason Sachs <jmsachs at gmail.com> wrote:
> Two more quick questions about clang:
>
> 1) Do the different levels of optimization (-O0 through -O4)
> correspond to particular optimization passes of the LLVM optimizer,
> and if so, what are they, and can I apply them after-the-fact on a
> program that was compiled with -O0? Not that this is necessarily
> practical, but I'm just trying to understand; the idea of separate
> optimization passes is intriguing.

Sort of... opt -O3 runs the same optimization passes as clang -O3, but
the result won't be precisely the same because the -O flags also
affect the translation from C to IR.  For debugging, the flag "-mllvm
-disable-llvm-optzns" can be useful.

> 2) Does llvm-dis have a name-demangling option, or is there an
> external demangler tool? I don't want to actually change the code, but
> it would be nice to see in the disassembled comments something like
>
> ; int Bar::sum2(int a, int b)
> define i32 @_ZN3Bar4sum2Eii(%class.Bar* nocapture %this, i32 %a, i32
> %b) nounwind readnone align 2 {

Have you tried just piping a .ll file through c++filt?

-Eli



More information about the cfe-dev mailing list