[LLVMdev] PHINode in entry block

Caldarale, Charles R Chuck.Caldarale at unisys.com
Tue Jul 15 08:28:47 PDT 2014


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of William Moses
> Subject: [LLVMdev] PHINode in entry block

> Consider the case where the entry block to a function acts like a loop (e.g. it 
> ends with a conditional break to itself and somewhere else). How would one create 
> a PHINode (representing an index perhaps) which has a constant index (say 0) when 
> entering the function, and (oldval+1) when looping.

> My question is how would one do this using the C++ API when there is no predecessor 
> since it is the entry block.

In this case you need to create an essentially empty entry block as a predecessor containing nothing but a branch to the starting block of the loop; its sole purpose is to provide a block for the PHI node to reference.

 - Chuck





More information about the llvm-dev mailing list