Doubts on SSA Update

Hi,

I’m trying to clone few basic blocks based on some information and keeping it closer to its predecessor.
For SSA update used SSAUpdater, but I’m not much confident on it.

i.e.
A:
Branch Cond1 L1, L2
B:
Branch Cond2 L1, L2
C*:*
Branch Cond**3 L1, L2

L1:

L2:

Will be translated to:

A:
Branch Cond1 L1.CloneA, L2.CLoneA
L1.CloneA:

L2.CLoneA:

B:
Branch Cond2 L1.CloneB, L2.CLoneB
L1.CloneB:

L2.CLoneB:

C:
Branch Cond3 L1, L2
L1:

L2:

After generating each clone updating SSA using SSAUpdater but I’m not very much confident as using it first time.
I’m worried about this incremental SSA update, is SSAUpdater safe for purpose like this ?

Probably I like to generate all the clones and update SSA in the last.
For that looking for a way where I can invalidate the SSA and later recreate it(Just like analysis invalidation)
I’m not aware of any way in LLVM where we can invalidate SSA and recreate it.

Any help on clarifying my doubts will be very useful.

Thanks,
Ashutosh