[LLVMdev] Disable optimization
Eli Friedman
eli.friedman at gmail.com
Fri Nov 28 01:31:33 PST 2008
On Fri, Nov 28, 2008 at 12:36 AM, RAAD B <raad_7007 at yahoo.com> wrote:
> Hi Eli,
>
> I want to disable optimizations because, i'm going to implement a framework
> in JAVA for educational purposes.
>
> I have planned to do followings:
>
> 1) Create LLVM-IR and export it as Assembly (without optimizing the
> source-code)
> 2) Transform the LLVM-Assembly to a data-structure, similar to LLVM data
> structure (Module, Function, BB ...) but implemented in Java
> 3) Optimizing the code (should be performed by students :-) )
> 4) Transform my data-structure to LLVM-Assembly.
> 5) Generate machine code using "llvm-as"
Ah, so roughly, Java bindings to LLVM? Interesting. Although, IMO,
for a topic as advanced as compilers, I don't think it would be a huge
burden to require using C++.
> Could you list me the other optimizations, which are performed by front-end?
I don't know the gcc front-end too well, so this is a rough list. The
obvious optimizations are constant folding and dead code elimination.
The front-end will also do local optimizations on expressions, like
optimizing "a+b-b" to "a". There might also be some other small stuff
I'm not remembering, but there aren't any other big optimizations
happening at -O0.
If you really want the dumbest possible conversion into bitcode, you
can probably hack up clang (http://clang.llvm.org) to disable all
optimizations... clang generally does less optimization, and if
there's some particular optimization you want to disable, finding it
should be easier. That said, it's probably not worth bothering; if
the point is to teach the students to write optimizers, it doesn't
really make a difference whether the code starts off slightly
optimized.
-Eli
More information about the llvm-dev
mailing list