Phi Node Question

I'm designing a JIT compiler and I have a potentially problematic situation.
The functions I compile may need to create/access an object during their
execution. In the case where this object won't be needed, I'd rather avoid
generating code to creating the object, as this is a slight performance
waste. Unfortunately, it's rather difficult to know whether this will be the
case without actually compiling the functions.

Thus, I have been thinking that I could generate code to create the said
object the first time it is needed by the function's code (during JIT
compilation). I would simply reserve an empty basic block at the start of
the function for this purpose, and insert the code there if needed. If the
object is needed, then I would insert the code to create it, and store a
pointer to it in an llvm::Value object.

Now, the question I have is as follows... If I only define this object once
at the start of the function, do I need to create phi nodes to propagate its
value everywhere, or can I keep using the same llvm::Value object everywhere
in the function, regargless of which basic block I'm currently in? There
will not be a case where this object is defined twice along separate
branches, it will always be defined only once at the start of the function
(entry basic block). However, if I have to create these phi nodes, it would
significantly complicate the addition of code to create the object, as I'd
have to go back and add all the phi nodes.

Thank you for your time,

- Max

If you put an instruction in the entry block, you can use the returned
value directly in every other block in the function; that's the magic
of SSA. If you're doing something more complicated, like creating a
variable whose value might change over the course of the function, you
can stick an alloca in the entry block, use loads and stores to modify
and access the value, and let the mem2reg pass take care of converting
it into PHI nodes. You never need to create a PHI node yourself if
you don't want to mess with figuring out how exactly they work.