Phi instructions for LLVM IR

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

In the next part of the code, I don't get any phi instructions for the bytecode:

int y, z;
y = f;

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

      

I know I can use the "-mem2reg" skip, but I would like to be able to see phi instructions in bytecode if possible.

+3


source to share


1 answer


Virtual registers in LLVM are in SSA form, but memory locations are not. It's convenient for LLVM frontends like Clang not to worry about the SSA form. If I use Clang to compile C code to LLVM IR, all variables are allocated on the stack. The SSA is not required as it z

is in memory.

If you are using



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

      

as suggested in previous comments, is z

no longer allocated on the stack, but in a virtual register. So you will also see the phi statement for your example to save the SSA form.

+4


source







All Articles