mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILBuilder: add an API to insert _after_ an instruction.
... and use that API in FullApplySite::insertAfterInvocation. Also change FullApplySite::insertAfterInvocation/insertAfterFullEvaluation to directly pass a SILBuilder instead of just an insertion point to the callback. This makes more sense (given the function names) and simplifies the usages. It's a NFC.
This commit is contained in:
@@ -661,3 +661,19 @@ CheckedCastBranchInst *SILBuilder::createCheckedCastBranch(
|
||||
destLoweredTy, destFormalTy, successBB, failureBB,
|
||||
getFunction(), C.OpenedArchetypes, target1Count, target2Count));
|
||||
}
|
||||
|
||||
void SILBuilderWithScope::insertAfter(SILInstruction *inst,
|
||||
function_ref<void(SILBuilder &)> func) {
|
||||
if (isa<TermInst>(inst)) {
|
||||
for (const SILSuccessor &succ : inst->getParent()->getSuccessors()) {
|
||||
SILBasicBlock *succBlock = succ;
|
||||
assert(succBlock->getSinglePredecessorBlock() == inst->getParent() &&
|
||||
"the terminator instruction must not have critical successors");
|
||||
SILBuilderWithScope builder(succBlock->begin());
|
||||
func(builder);
|
||||
}
|
||||
} else {
|
||||
SILBuilderWithScope builder(std::next(inst->getIterator()));
|
||||
func(builder);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user