Phi instructions on LLVM IR

Is there any way to get 'phi' instructions on .ll files ?

For the following part of code, I don't get any 'phi' instructions on the bytecode:

int y, z;
y = f;

if (y < 0)
    z = y + 1;
    z = y + 2;
return z;

I know that I can use the pass "-mem2reg", but I would like,if this is possible, to be able to see the phi instructions on the bytecode.


Virtual registers in LLVM are in SSA form, while memory cells are not. For LLVM frontends such as Clang it is convenient to not have to care about SSA form. If I use Clang to compile the C code to LLVM IR, all the variables are allocated on the stack. No SSA form is needed, since z lies in memory.

If you use

opt -mem2reg -S example.ll -o example-opt.ll

as suggested in the previous comments, z is no longer allocated on the stack but in a virtual register. Thus, you will also see a phi instruction for your example to maintain SSA form.

Need Your Help

ASP.NET MVC 5 Identity AddUserToRole not works

I'm trying to insert initial users, roles and attach users to roles using ASP.NET MVC 5 Identity.