[LLVMdev] recreate optimized clang output

John McCall rjmccall at apple.com
Tue Jan 25 19:39:14 PST 2011


On Jan 24, 2011, at 10:36 AM, Hendrix_ at gmx.net wrote:
> I was using "clang  -O3 -S -emit-llvm" got some very optimized output.
> 
> Then I did "clang -S -emit-llvm" (without optimization) and wanted to optimized the code in a
> separate pass. The llvm program "opt" did not do anything.
> 
> How can I invoke the optimizer on some un-optimized program, possibly showing the output of each optimizer stage?
> I would like to get a deeper understanding of the optimization pass.

In addition to Sam's advice, I want to point out that clang's IR generator doesn't necessarily emit the same code when compiling for optimization and not.  Most obviously, we never emit available_externally function definitions at -O0 because we assume that would just waste compile time.

John.



More information about the llvm-dev mailing list