SIL: some Cloner cleanups and improvements

* move some Cloner utilities from ContextCommon.swift directly into Cloner.swift
* add an `cloneRecursively` overload which doesn't require the `customGetCloned` closure argument
* some small cleanups
This commit is contained in:
Erik Eckstein
2025-09-03 09:00:00 +02:00
parent 65d69fe965
commit 231042b9a8
5 changed files with 30 additions and 30 deletions

View File

@@ -164,26 +164,6 @@ extension Instruction {
}
}
extension Cloner where Context == FunctionPassContext {
func getOrCreateEntryBlock() -> BasicBlock {
if let entryBlock = targetFunction.blocks.first {
return entryBlock
}
return targetFunction.appendNewBlock(context)
}
func cloneFunctionBody(from originalFunction: Function, entryBlockArguments: [Value]) {
entryBlockArguments.withBridgedValues { bridgedEntryBlockArgs in
let entryBlock = getOrCreateEntryBlock()
bridged.cloneFunctionBody(originalFunction.bridged, entryBlock.bridged, bridgedEntryBlockArgs)
}
}
func cloneFunctionBody(from originalFunction: Function) {
bridged.cloneFunctionBody(originalFunction.bridged)
}
}
func cloneFunction(from originalFunction: Function, toEmpty targetFunction: Function, _ context: FunctionPassContext) {
var cloner = Cloner(cloneToEmptyFunction: targetFunction, context)
defer { cloner.deinitialize() }