[LLVMdev] Bug in opt

Duncan Sands baldrick at free.fr
Wed Mar 16 06:59:08 PDT 2011


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.

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



More information about the llvm-dev mailing list