Hi, 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. Best, Patrick
Hi Patrick, You have to tell opt which optimizations you want it to do. The -std-compile-opts option for opt may be what you're looking for. --Sam ----- Original Message ----> From: "Hendrix_ at gmx.net" <Hendrix_ at gmx.net> > To: llvmdev at cs.uiuc.edu > Sent: Mon, January 24, 2011 12:36:42 PM > Subject: [LLVMdev] recreate optimized clang output > > Hi, > > 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. > > Best, > Patrick > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
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.
On 26.01.2011, at 04:39, John McCall wrote:> 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.OK, I am looking for "LTO"/global optimization. So the function definition will remain "somewhere else" (externally), and the optimizer will find in some other module to possibly inline it later on. I am planning to concat all the *.ll (eg "link" the files) and pass them to the "global" optimizer, as "size" is a very important optimization criterium to me. After that, the back-end will be invoked. Is that a good approach? Best, Patrick