[LLVMdev] Can I disable the optimizaiton for llvmgcc?

John Criswell criswell at cs.uiuc.edu
Fri May 14 13:46:13 PDT 2004


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.          *
*********************************************************************





More information about the llvm-dev mailing list