Is there a concept of minimum instruction level at the LLVM IR level?

I would like to know LLVM IR under different optimization options (e.g. -O0 -O1 …) What is the difference under different optimization options (e.g. -O0 -O1 …)?

Is it possible to use only some of the fixed instructions under the -O0 option?

I want to construct a VM to execute IR under the -O0 optimization, but I don’t want to analyze the full IR instructions.

Looking forward to your reply!

LLVM IR does not have a built-in concept of IR levels, the way some other IRs do (GEM, Open64).

There is already an IR interpreter, look at the lli tool, which might be helpful for your project.

1 Like

Thank you for your reply.
I will try to use lli, also I would like to ask if there is a way to control the kind of instructions generated by IR?

I’m not sure I understand the question. Do you mean, is there a way to control the kind of IR instructions generated by Clang? In general, Clang will translate C/C++ code into IR instructions in a straightforward way, and the only way to affect what it produces is to give it different C/C++ input.

For example, if you give Clang a source file that does not use exceptions, you can expect that it will not emit any instructions related to exception handling (invoke, landingpad).

If you are trying to ask a different question, please give more details about your project.

1 Like

Thank you for solving my problem.