Module PhiInsertion
Module to handle insertion of Phi
instructions at the correct blocks. We insert a Phi
instruction at the
beginning of a block for a given location when that block is on the dominance frontier of a definition of the
location and there is a use of that location reachable from that block without an intervening definition of the
location.
Within the approach outlined above, we treat a location slightly differently depending on whether or not it is a
virtual variable. For a virtual variable, we will insert a Phi
instruction on the dominance frontier if there is
a use of any member location of that virtual variable that is reachable from the Phi
instruction. For a location
that is not a virtual variable, we insert a Phi
instruction only if there is an exactly-overlapping use of the
location reachable from the Phi
instruction. This ensures that we insert a Phi
instruction for a non-virtual
variable only if doing so would allow dataflow analysis to get a more precise result than if we just used a Phi
instruction for the virtual variable as a whole.
Import path
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConstruction
Predicates
definitionHasPhiNode | Holds if a |
definitionLiveOnEntryToBlock | Holds if the definition |
definitionLiveOnExitFromBlock | Holds if the definition |