mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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() }
|
||||
|
||||
Reference in New Issue
Block a user