- if (Director) {
- CloningDirector::CloningAction Action
- = Director->handleInstruction(VMap, OldTI, NewBB);
- // If the cloning director says stop, we want to stop everything, not
- // just break out of the loop (which would cause the terminator to be
- // cloned). The cloning director is responsible for inserting a proper
- // terminator into the new basic block in this case.
- if (Action == CloningDirector::StopCloningBB)
- return;
- if (Action == CloningDirector::CloneSuccessors) {
- // If the director says to skip with a terminate instruction, we still
- // need to clone this block's successors.
- const TerminatorInst *TI = NewBB->getTerminator();
- for (const BasicBlock *Succ : TI->successors())
- ToClone.push_back(Succ);
- return;
- }
- assert(Action != CloningDirector::SkipInstruction &&
- "SkipInstruction is not valid for terminators.");
- }