Thank you very much for your talk.
I think I could append more information about updating LiveIntervals.
1. It works well if I just use from step1 to step3, without step4.
2. In step4, I firstly use UnreachableBlockElim pass to delete OldMBB.
Then, remove all intervals and recompute all the virtual registers' LiveIntervals.
3. I debug source code in LiveRangeCalc.cpp and copy partial code shown following.
/// LiveRangeCalc.cpp
...
#ifndef NDEBUG
if (MBB->pred_empty()) {
MBB->getParent()->verify();
llvm_unreachable("Use not jointly dominated by defs.");
}
...
/// LiveRangeCalc.cpp
This MBB is the first block of MachineFunction. That's to say, This MBB doesn't have predecessor. It is reasonable?
From debug information, this unreachable error is generated from recompute a virtual register which isn't used or defined in this MBB. But this virtual register, in NewMBB, is defined in a machine instruction which is copied from OldMBB.
So I am puzzled.
Then, I do as Andy's suggestion, but it doesn't work, and it has same error.
Could you have any suggestion?