Thanks Duncan. Just to make sure I understand correctly, opt has more global information, due to which optimizations can have greater effect than in llvm-gcc, where optimizations are applied on a per-function basis. Is this correct ? ----- Original Message ----- From: "Duncan Sands" <baldrick at free.fr> To: llvmdev at cs.uiuc.edu Sent: Tuesday, December 13, 2011 2:46:23 AM Subject: Re: [LLVMdev] Optimization application by llvm-gcc, opt Hi RaghuB,> I wanted to clarify something about the application of optimizations by llvm-gcc, opt and llc. > > Will the following two sequences generate the same optimized bitcode? > a) $ llvm-gcc -O3 -c -emit-llvm foo.c -o foo.bc > b) $ llvm-gcc -O0 -c -emit-llvm foo.c -o foo.bc > $ opt -O3 foo.bcnot necessarily, though usually it is the same. One reason for this is that the per-function passes run by llvm-gcc are used to clean up functions as they are output, while with opt they are run after the entire module has been generated. The difference is that when a function is output some things like global variables may have only been partially output (eg may not have an initial value yet) resulting in less or different optimization. Ciao, Duncan. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Raghu,> Thanks Duncan. Just to make sure I understand correctly, opt has more global information, due to which optimizations can have greater effect than in llvm-gcc, where optimizations are applied on a per-function basis. Is this correct ?if you look carefully at what "opt -O3" runs (using -debug-pass=Arguments) you will see that it first runs a small list of passes (the "per function" passes), and later runs a much more complete list of passes. As each function is output, llvm-gcc runs these "per-function" passes on it. Once the entire module is output, llvm-gcc runs the second list of passes on the whole module. Thus it is not correct to say that optimizations are applied only on a per-function basis in llvm-gcc. On the other hand opt applies both lists of passes to the entire module. Your remark "opt has more global information, due to which optimizations can have greater effect than in llvm-gcc" is correct, but only applies to the first list of passes, since for the second list of passes llvm-gcc also has the entire module available when applying them. Ciao, Duncan.
Got it. Thanks for the detailed explanation Duncan. ----- Original Message ----- From: "Duncan Sands" <baldrick at free.fr> To: "Raghu Prabhakar" <raghu at cs.ucla.edu> Cc: llvmdev at cs.uiuc.edu Sent: Tuesday, December 13, 2011 12:15:22 PM Subject: Re: [LLVMdev] Optimization application by llvm-gcc, opt Hi Raghu,> Thanks Duncan. Just to make sure I understand correctly, opt has more global information, due to which optimizations can have greater effect than in llvm-gcc, where optimizations are applied on a per-function basis. Is this correct ?if you look carefully at what "opt -O3" runs (using -debug-pass=Arguments) you will see that it first runs a small list of passes (the "per function" passes), and later runs a much more complete list of passes. As each function is output, llvm-gcc runs these "per-function" passes on it. Once the entire module is output, llvm-gcc runs the second list of passes on the whole module. Thus it is not correct to say that optimizations are applied only on a per-function basis in llvm-gcc. On the other hand opt applies both lists of passes to the entire module. Your remark "opt has more global information, due to which optimizations can have greater effect than in llvm-gcc" is correct, but only applies to the first list of passes, since for the second list of passes llvm-gcc also has the entire module available when applying them. Ciao, Duncan.
Possibly Parallel Threads
- [LLVMdev] Optimization application by llvm-gcc, opt
- [LLVMdev] Query on llvm-gcc v/s llc/as
- [LLVMdev] Issue compiling llvm-gcc frontend on sparc
- [LLVMdev] install and add backend to llvm.
- [LLVMdev] Modifying the patterns/ instruction selection phase in LLVM 2.7