[LLVMdev] PHI nodes in machine code

Chris Lattner sabre at nondot.org
Thu Jul 8 11:58:01 PDT 2004


On Thu, 8 Jul 2004, Misha Brukman wrote:

> On Thu, Jul 08, 2004 at 11:12:58AM -0500, Vikram Adve wrote:
> > PHI nodes within machine code were originally used by the Sparc
> > back-end but they turned out not to be necessary.
>
> Actually, they are currently used in non-SparcV9 backends (see below).

Misha's right.  In the target-independent code generator, the instruction
selector is required to translate LLVM PHI nodes into machine code PHI
nodes, and is allowed to create any additional PHI nodes that it needs.
Misha points out that setcc and select instructions are two common cases
where machine code phi's may be needed where LLVM PHI's don't exist.
Volodya also needs them for 64-bit integer compares (FYI, the X86 backend
has similar needs, but works around them by using conditional moves).

In general, the machine code CFG is more complex and may be slightly
different than the LLVM CFG.  It is the goal of the code generator to make
it so that NO LLVM state needs to be consulted for code generation after
instruction selection.  We're not quite there yet, but are very close.

Specifically w.r.t. machine code PHI nodes, they are created by the
instruction selector, possibly manipulated by machine code optimizations,
then eliminated by the register allocator.  SSA makes it really trivial to
sparsely compute live-variable information, for example, which is used by
all of the target-independent LLVM register allocators.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list