I am trying to implement a pass that will answer queries like isAlive(var,n) where n is a basic block and var is any SSA variable. isAlive returns true if var is alive in the basic block n.
From what I have understood dominators and use-def chain should be enough to do this perhaps?
What I have in mind is:
let def(var) be the basic block that defines var. if def(var) dominates n (any other basic block) and n dominates at least one block that has a use of var. Then var is alive in n?
However, I am thinking of instructions that can clobber the memory for var (StoreInsts in LLVM) so then essentially I would have multiple def(var) blocks(?)
Will the algorithm then be if a single def(var) [from all the def(var) blocks] dominates n followed by n dominating any one block that has the use of var?
Any help on this will be appreciated. Thanks!