Hi all LLVMor, I just tried to compile a simple code and analyze the number of the basic blocks. But after compile, what I got, the bytecode is seems to be optimized bytecode. So the information of basic blocks is not what I expected. I want ot use the code as example to see how some of code optimization methods work. However, after compiling file using llvm test.c -o test, bytecode file test.bc is optimized ( llvm-dis< test.bc). Does it mean there is default optimaztion option when running llvmgcc and can I disable the option for optimiztion? By the way, I can get the almost exactly matched assemble code by using original gcc -c test.c. Thanks, Qiuyu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20040514/a585cbd7/attachment.html>
On Fri, May 14, 2004 at 11:39:39AM -0700, Zhang Qiuyu wrote:> I just tried to compile a simple code and analyze the number of the > basic blocks. But after compile, what I got, the bytecode is seems to > be optimized bytecode. So the information of basic blocks is not what > I expected. I want ot use the code as example to see how some of code > optimization methods work. However, after compiling file using llvm > test.c -o test, bytecode file test.bc is optimized ( llvm-dis< > test.bc). Does it mean there is default optimaztion option when > running llvmgcc and can I disable the option for optimiztion?Yes, by default, llvm-gcc will run gccas after compiling C/C++ to LLVM assembly, then gccas will assemble the code and run various optimizations on it. To see a list of passes gccas will run on your code: gccas -debug-pass=Arguments < /dev/null -o - > /dev/null To disable running these optimizations on your code: llvm-gcc -S file.c llvm-as < file.s > file.bc The -S produces just the assembly that llvm-gcc would normally produce and inhibits running gccas on that code. llvm-as is a pure assembler, where as gccas is an optimizing assembler built to clean up after the code that llvm-gcc produces, which includes simplifying the CFG, so you are seeing basic blocks go away. -- Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
Zhang Qiuyu wrote:> Hi all LLVMor, > > I just tried to compile a simple code and analyze the number of the > basic blocks. But after compile, what I got, the bytecode is seems to be > optimized bytecode. So the information of basic blocks is not what I > expected. I want ot use the code as example to see how some of code > optimization methods work. However, after compiling file using llvm > test.c -o test, bytecode file test.bc is optimized ( llvm-dis< > test.bc). Does it mean there is default optimaztion option when running > llvmgcc and can I disable the option for optimiztion? > > By the way, I can get the almost exactly matched assemble code by using > original gcc -c test.c. > > Thanks, > Qiuyu >Actually, it is not GCC that is doing the optimizations. llvm-gcc uses gccas and gccld to assemble and link code. By default, gccas and gccld run optimizations before generating the output bytecode file. There are two ways to get unoptimized bytecode: 1) Use the -Wa,-disable-opt and -Wl,-disable-opt when using llvm-gcc. This passes the -disable-opt command line option to gccas and gccld, respectively: % llvm-gcc -o program -Wa,-disable-opt -Wl,-disable-opt file1.c file2.c 2) Compile the program to LLVM assembly language and then assemble it and link it with llvm-as and llvm-link: % llvm-gcc -S -o file1.ll file1.c % llvm-gcc -S -o file2.ll file2.c % llvm-as file1.ll % llvm-as file2.ll % gccld -disable-opt -o program.bc file1.bc file2.bc -lc % # We use gccld here because it is better equipped to find libc Hope that helps. Please feel free to send email to the list if you continue to have problems. -- John T. -- ********************************************************************* * John T. Criswell Email: criswell at uiuc.edu * * Research Programmer * * University of Illinois at Urbana-Champaign * * * * "It's today!" said Piglet. "My favorite day," said Pooh. * *********************************************************************