[WinEH] Update PHIs of CATCHRET successors
[oota-llvm.git] / lib / Target / X86 / X86ISelLowering.cpp
index f5efd58e7a384ce0856be6a27c2e1cbd72dc801c..8d7712d3cd07a4de22e5ceba0e14417afdc838af 100644 (file)
@@ -21419,10 +21419,10 @@ X86TargetLowering::EmitLoweredCatchRet(MachineInstr *MI,
   // the new block to the return destination with a normal JMP_4.
   MachineBasicBlock *RestoreMBB =
       MF->CreateMachineBasicBlock(BB->getBasicBlock());
+  assert(BB->succ_size() == 1);
   MF->insert(TargetMBB->getIterator(), RestoreMBB);
-  BB->removeSuccessor(TargetMBB);
+  RestoreMBB->transferSuccessorsAndUpdatePHIs(BB);
   BB->addSuccessor(RestoreMBB);
-  RestoreMBB->addSuccessor(TargetMBB);
   MI->getOperand(0).setMBB(RestoreMBB);
 
   auto RestoreMBBI = RestoreMBB->begin();