Un-SSA pass and cloning basic blocks


Sorry if this question has been asked earlier:

Is the -reg2mem the pass to convert SSA form of LLVM IR to non-SSA
form (ie, eliminate all phi-functions from LLVM IR) ? I tried it with
a small example and it did remove all the phi function, I just wanted
to confirm that the pass guarantees to remove all phi functions. Also,
assuming I have this pass as a required pass, is it safe to clone
basic blocks within a function (while respecting dominance property of
existing blocks) to help for example, path-specific optimizations that
might be benefited by node splitting ?


-reg2mem is the un-SSA pass. I believe it is guaranteed to remove all phi nodes (in fact, I'm pretty sure it works by iterating over all phi nodes). Andrew Lenharth will correct me if I'm wrong.