[LLVMdev] Bug in opt

Joe Armstrong joearms at gmail.com
Wed Mar 16 09:05:21 PDT 2011


On Wed, Mar 16, 2011 at 2:59 PM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Joe,
>
>> I have made a .s file, which can be correctly assembled
>> and run with lli. But when I optimize it I get no errors
>> from the optimizer, but the resultant file is incorrect.
>>
>> Here's what happens:
>>
>> llvm-as test2_gen.s   %% no errors test2_gen.s.bc is produced
>
> there's actually no need to assemble this to bitcode: you can pass
> test2_gen.s directly to opt.  At least you can in recent versions of
> LLVM.
>
>> opt -std-compile-opts -S test2_gen.s.bc>  test2_opt.s.bc
>
> By using -S you ask opt to produce human readable IR rather than
> bitcode, so you should really output to test2_opt.s.
>
>>
>> %% no errors
>> %% But now the generated file cannon be disassembled or run
>>
>> lli test2_opt.s.bc
>> lli: error loading program 'test2_opt.s.bc': Bitcode stream should be a
>> multiple
>> of 4 bytes in length
>
> This means that it doesn't contain bitcode.  And indeed it doesn't, it
> contains human readable IR due to your using -S above.

Silly me I didn't think to look - you're right.

This is very cool - my C compiler spits out lousy code, but after
"opt'ing" the result
more or less results in what as optimising C compiler would have spit out.

Which means that language interoperability becomes really easy - just
parse and de-sugar
the input (form any language) and your're away.

Thanks for you help

/Joe




>
>> llvm-dis test2_opt.s.bc
>> llvm-dis: Bitcode stream should be a multiple of 4 bytes in length
>
> Same problem.
>
> That said, in latest LLVM lli accepts human readable IR as well as bitcode,
> so I'm guessing that you are using an older version that does not have this
> feature.  Of course I may also have misdiagnosed the problem :)
>
> Ciao, Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list