Reputation: 51
I have compiled the C code to LLVM
IR code with -O0
optimization.
How can I convert this -O0
LLVM IR code to the -O3
LLVM
IR code "without the C code"?
I have tried below:
clang -O3 -S -emit-llvm O0.ll -o O3.ll
and
opt -O3 -S O0.ll -o O3.ll
but the output is still -O0
level.
Thank you.
Upvotes: 4
Views: 935
Reputation: 2339
I'm not sure when the change happened (I think it's LLVM
3.9.0 and on), but when you compile to bitcode functions get annotated with the optnone
attribute and further optimizations are not performed.
Have a look for a relevant SO discussion here.
What is suggested is to do this:
clang -emit-llvm -O1 -mllvm -disable-llvm-optzns -disable-llvm-passes foo.c -o foo.bc
For LLVM
3.8.0 and earlier (I think) what you have already been doing is enough.
So, once you obtain that bitcode (without the optnone
) argument, you can use opt
as you've already been doing.
Upvotes: 1