Problems on getting the OPT resultant bitcode


Hi,


I want to write a piece of code to instrument c++ programs. I have finished writing the pass, but I do not know how to get the resultant bitcode

I ran OPT with the following arguments:


opt -basiccg -basicaa -load /home/andy/llvm-3.0.src/Release/lib/InstTest.so -InstTest </home/andy/llvm-3.0.src/workspace/threadTest/Debug/threadTest.bc> -o=</home/andy/output/out.bc> /dev/null


where </home/andy/llvm-3.0.src/workspace/threadTest/Debug/threadTest.bc> is the input file, and </home/andy/output/out.bc> is the expected output file. InstTest is my pass.


However, opt treat </home/andy/output/out.bc> as the input file, and I cannot find any output any where. Also, if I donot use the “-o” argument, the input is </home/andy/llvm-3.0.src/workspace/threadTest/Debug/threadTest.bc> as expected but still I cannot find the output (the resultant bitcode).


What should I do?


I am expecting for your reply. Thank you very much.


Best Regards,
Andy
|

Hi Andy,

I want to write a piece of code to instrument c++ programs. I have finished
writing the pass, but I do not know how to get the resultant bitcode

I ran OPT with the following arguments:

opt -basiccg -basicaa -load /home/andy/llvm-3.0.src/Release/lib/InstTest.so
-InstTest </home/andy/llvm-3.0.src/workspace/threadTest/Debug/threadTest.bc>
-o=</home/andy/output/out.bc> /dev/null

are you really using "<" and ">" here, or were they just for emphasis? The
shell interprets "<" and ">" as input and output redirectors so you will get
strange behaviour if you use them like this. Also, there is no need to use
an equals sign "=" after -o, it can just be "-o /home/andy/output/out.bc".
Finally, why did you put /dev/null?

Anyway, try this:

opt -basiccg -basicaa -load /home/andy/llvm-3.0.src/Release/lib/InstTest.so -InstTest /home/andy/llvm-3.0.src/workspace/threadTest/Debug/threadTest.bc -o /home/andy/output/out.bc

Ciao, Duncan.

Hi,


I am currently using llvm to compile memcache to get the bitcode. I simply change all the “gcc -c” command to “clang -emit-llvm -c”, and output “.o” to “.bc”. And all gcc link command to llvm-ld. By these means, I successfully get the bitcode file, but when I run it using “lli”, it fails with the error:


UNREACHABLE executed!
0 lli 0x087c2cab
Stack dump:
0. Program arguments lli timedrun.bc
1. Running Pass ‘X86 Machine Code Emitter’ on function @main
aborted


I encountered the same error when executing other executables in the project. Why does this happen? Is there any suggestions to get rid of such problem?


Thank you


Best
Andy



|

Hi Andy,

I am currently using llvm to compile memcache to get the bitcode. I simply
change all the "gcc -c" command to "clang -emit-llvm -c", and output ".o" to
".bc". And all gcc link command to llvm-ld. By these means, I successfully get
the bitcode file, but when I run it using "lli", it fails with the error:

UNREACHABLE executed!
0 lli 0x087c2cab
Stack dump:
0. Program arguments lli timedrun.bc
1. Running Pass 'X86 Machine Code Emitter' on function @main
aborted

I encountered the same error when executing other executables in the project.
Why does this happen? Is there any suggestions to get rid of such problem?

this probably means that the bitcode contains something that is not supported
by lli, such as inline assembler. Try passing the -use-mcjit option to lli.
If that doesn't work, feel free to open a bugreport and attach the bitcode.

Ciao, Duncan.

Dear Ciao, Duncan,


Thank you for replying. I tried and the error goes away. But there comes a new error:


LLVM ERROR: Unknown object format!


How can I solve this problem?


Thank you!


Best
Andy
12年9月18日,周二, Duncan Sands baldrick@free.fr 写道:


> 发件人: Duncan Sands baldrick@free.fr
> 主题: Re: [LLVMdev] Problems on getting UNREACHABLE executed
> 收件人: llvmdev@cs.uiuc.edu
> 日期: 2012年9月18日,周二,下午4:02
>
> Hi Andy,
>
> > I am currently using llvm to compile memcache to get the bitcode. I simply
> > change all the “gcc -c” command to “clang -emit-llvm -c”, and output “.o” to
> > “.bc”. And all gcc link command to llvm-ld. By these means, I successfully get
> > the bitcode file, but when I run it using “lli”, it fails with the error:
> >
> > UNREACHABLE executed!
> > 0 lli 0x087c2cab
> > Stack dump:
> > 0. Program arguments lli timedrun.bc
> > 1. Running Pass ‘X86 Machine Code Emitter’ on function @main
> > aborted
> >
> > I encountered the same error when executing other executables in the project.
> > Why does this happen? Is there any suggestions to get rid of such problem?
>
> this probably means that the bitcode contains something that is not supported
> by lli, such as inline assembler. Try passing the -use-mcjit option to lli.
> If that doesn’t work, feel free to open a bugreport and attach the bitcode.
>
> Ciao, Duncan.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


|

Hi Andy,

Thank you for replying. I tried and the error goes away. But there comes a new
error:

LLVM ERROR: Unknown object format!

How can I solve this problem?

I don't know, sorry.

Best wishes, Duncan.