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:
Erik Eckstein
2020-10-16 16:23:13 +02:00
parent 6310dfcc93
commit 9a10ec7d58
8 changed files with 101 additions and 64 deletions

View File

@@ -2499,6 +2499,20 @@ public:
assert(DS && "Instruction without debug scope associated!");
setCurrentDebugScope(DS);
}
/// If \p inst is a terminator apply site, then pass a builder to insert at
/// the first instruction of each successor to \p func. Otherwise, pass a
/// builder to insert at std::next(inst).
///
/// The intention is that this abstraction will enable the compiler writer to
/// ignore whether or not \p inst is a terminator when inserting instructions
/// after \p inst.
///
/// Precondition: It's the responsibility of the caller to ensure that if
/// \p inst is a terminator, all successor blocks have only a single
/// predecessor block: the parent of \p inst.
static void insertAfter(SILInstruction *inst,
function_ref<void(SILBuilder &)> func);
};
class SavedInsertionPointRAII {