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" Could you list me the other optimizations, which are performed by front-end? Raad ________________________________ From: Eli Friedman <eli.friedman at gmail.com> To: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu> Sent: Thursday, November 27, 2008 10:39:21 PM Subject: Re: [LLVMdev] Disable optimization On Thu, Nov 27, 2008 at 6:14 AM, RAAD B <raad_7007 at yahoo.com> wrote:> Hello together, > > although i use the "-O0" flag as follow, the llvm perform dead code > elimination. > How can i disable optimizing completely?Sorry, it's not possible; the gcc front-end does some optimizations which the LLVM backend can't do anything about, and dead code elimination can arise naturally out of the approach LLVM uses for code generation. Note that -O0 really means "generate code as quickly as possible, and don't do any optimizations which reduce the quality of debug symbols". Why exactly do you want to disable dead code elimination anyway? I can't see any reason why you'd want dead code in the generated program, unless you're abusing asm statements or something like that. -Eli _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081128/3125f698/attachment.html>
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
On Fri, Nov 28, 2008 at 11:31 AM, Eli Friedman <eli.friedman at gmail.com> wrote:> 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.It matters if the optimisations the students have to implement are the optimisations done implicitly by LLVM. -- . ..: Lucian