[LLVMdev] Phi Node Question

Nyx mcheva at cs.mcgill.ca
Tue Jun 9 18:15:00 PDT 2009


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
-- 
View this message in context: http://www.nabble.com/Phi-Node-Question-tp23953992p23953992.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list