[LLVMdev] Variable-length Phi-node

David Chisnall David.Chisnall at cl.cam.ac.uk
Sat Nov 9 09:56:00 PST 2013


On 9 Nov 2013, at 16:35, William Moses <moses.williamsteven at gmail.com> wrote:

> Is it possible to create something which has the same effect of a variable-length phi node in the C++ api. Specifically, create a phi-node where the number of incoming values is not known at the time of its creation.

The PHI node preallocates its storage, so no.

> If there is no such way of creating a phinode like that, would it be possible to create a dummy instruction and perform a replaceAllUsesWith? If so, what should the dummy instruction be?

You could use a PHI node with a small number if incoming blocks, and when you go past that number you could replace it with another one.  Ideally though, you'd defer creating the block with the PHI node in it until you knew what the CFG would look like.  What are you doing that means that you don't know how many incoming blocks a block has when you create it?

David





More information about the llvm-dev mailing list