Skip to content

Commit 6374f02

Browse files
committed
Handle return_borrow in a few more places in SwiftCompilerSources
1 parent a0d33c3 commit 6374f02

File tree

11 files changed

+50
-20
lines changed

11 files changed

+50
-20
lines changed

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ private struct FullApplyEffectsVisitor : EscapeVisitorWithResult {
775775

776776
mutating func visitUse(operand: Operand, path: EscapePath) -> UseResult {
777777
let user = operand.instruction
778-
if user is ReturnInst {
778+
if user is ReturnInstruction {
779779
// Anything which is returned cannot escape to an instruction inside the function.
780780
return .ignore
781781
}
@@ -805,7 +805,7 @@ private struct PartialApplyEffectsVisitor : EscapeVisitorWithResult {
805805

806806
mutating func visitUse(operand: Operand, path: EscapePath) -> UseResult {
807807
let user = operand.instruction
808-
if user is ReturnInst {
808+
if user is ReturnInstruction {
809809
// Anything which is returned cannot escape to an instruction inside the function.
810810
return .ignore
811811
}
@@ -848,7 +848,7 @@ private struct EscapesToInstructionVisitor : EscapeVisitor {
848848
if user == target {
849849
return .abort
850850
}
851-
if user is ReturnInst {
851+
if user is ReturnInstruction {
852852
// Anything which is returned cannot escape to an instruction inside the function.
853853
return .ignore
854854
}

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeEscapeEffects.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ let computeEscapeEffects = FunctionPass(name: "compute-escape-effects") {
8181
private
8282
func addArgEffects(_ arg: FunctionArgument, argPath ap: SmallProjectionPath,
8383
to newEffects: inout [EscapeEffects.ArgumentEffect],
84-
_ returnInst: ReturnInst?, _ context: FunctionPassContext) -> Bool {
84+
_ returnInst: ReturnInstruction?, _ context: FunctionPassContext) -> Bool {
8585
// Correct the path if the argument is not a class reference itself, but a value type
8686
// containing one or more references.
8787
let argPath = arg.type.isClass ? ap : ap.push(.anyValueFields)
@@ -157,7 +157,7 @@ private struct ArgEffectsVisitor : EscapeVisitorWithResult {
157157
var result = EscapeDestination.notSet
158158

159159
mutating func visitUse(operand: Operand, path: EscapePath) -> UseResult {
160-
if operand.instruction is ReturnInst {
160+
if operand.instruction is ReturnInstruction {
161161
// The argument escapes to the function return
162162
if path.followStores {
163163
// The escaping path must not introduce a followStores.
@@ -209,13 +209,13 @@ private struct IsExclusiveReturnEscapeVisitor : EscapeVisitorWithResult {
209209
let returnPath: SmallProjectionPath
210210
var result = false
211211

212-
func isExclusiveEscape(returnInst: ReturnInst, _ context: FunctionPassContext) -> Bool {
212+
func isExclusiveEscape(returnInst: ReturnInstruction, _ context: FunctionPassContext) -> Bool {
213213
return returnInst.returnedValue.at(returnPath).visit(using: self, context) ?? false
214214
}
215215

216216
mutating func visitUse(operand: Operand, path: EscapePath) -> UseResult {
217217
switch operand.instruction {
218-
case is ReturnInst:
218+
case is ReturnInstruction:
219219
if path.followStores { return .abort }
220220
if path.projectionPath.matches(pattern: returnPath) {
221221
return .ignore

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private struct CollectedEffects {
254254
// effect, it would not give any significant benefit in any of our current optimizations.
255255
addEffects(.destroy, to: inst.operands[0].value, fromInitialPath: SmallProjectionPath(.anyValueFields))
256256

257-
case is ReturnInst:
257+
case is ReturnInstruction:
258258
if inst.parentFunction.convention.hasAddressResult {
259259
addEffects(.read, to: inst.operands[0].value)
260260
}
@@ -532,7 +532,7 @@ private struct ArgumentEscapingWalker : ValueDefUseWalker, AddressDefUseWalker {
532532
case is CopyValueInst, is RetainValueInst, is StrongRetainInst,
533533
is DestroyValueInst, is ReleaseValueInst, is StrongReleaseInst,
534534
is DebugValueInst, is UnconditionalCheckedCastInst,
535-
is ReturnInst:
535+
is ReturnInstruction:
536536
return .continueWalk
537537

538538
case let apply as ApplySite:
@@ -620,7 +620,7 @@ private extension PartialApplyInst {
620620
// Any escape to apply - regardless if it's an argument or the callee operand - might cause
621621
// the closure to be called.
622622
return .abort
623-
case is ReturnInst:
623+
case is ReturnInstruction:
624624
return .ignore
625625
default:
626626
return .continueWalk

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ extension ExtendableScope {
894894
assert(end.parentBlock.singleSuccessor!.terminator is ReturnInst,
895895
"a phi only ends a use range if it is a returned value")
896896
fallthrough
897-
case is ReturnInst:
897+
case is ReturnInstruction:
898898
// End this inner scope just before the return. The mark_dependence base operand will be redirected to a
899899
// function argument.
900900
let builder = Builder(before: end, location: location, context)

SwiftCompilerSources/Sources/Optimizer/TestPasses/EscapeInfoDumper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let escapeInfoDumper = FunctionPass(name: "dump-escape-info") {
2626
var result: Set<String> = Set()
2727

2828
mutating func visitUse(operand: Operand, path: EscapePath) -> UseResult {
29-
if operand.instruction is ReturnInst {
29+
if operand.instruction is ReturnInstruction {
3030
result.insert("return[\(path.projectionPath)]")
3131
return .ignore
3232
}
@@ -94,7 +94,7 @@ let addressEscapeInfoDumper = FunctionPass(name: "dump-addr-escape-info") {
9494
if user == apply {
9595
return .abort
9696
}
97-
if user is ReturnInst {
97+
if user is ReturnInstruction {
9898
// Anything which is returned cannot escape to an instruction inside the function.
9999
return .ignore
100100
}

SwiftCompilerSources/Sources/Optimizer/Utilities/EscapeUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
387387
if handleDestroy(of: operand.value, path: path) == .abortWalk {
388388
return .abortWalk
389389
}
390-
case is ReturnInst:
390+
case is ReturnInstruction:
391391
return isEscaping
392392
case is ApplyInst, is TryApplyInst, is BeginApplyInst:
393393
return walkDownCallee(argOp: operand, apply: instruction as! FullApplySite, path: path)
@@ -534,7 +534,7 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
534534
if handleDestroy(of: operand.value, path: path) == .abortWalk {
535535
return .abortWalk
536536
}
537-
case is ReturnInst:
537+
case is ReturnInstruction:
538538
return isEscaping
539539
case is ApplyInst, is TryApplyInst, is BeginApplyInst:
540540
return walkDownCallee(argOp: operand, apply: instruction as! FullApplySite, path: path)

SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ extension LifetimeDependenceDefUseWalker {
727727
if let apply = operand.instruction as? FullApplySite {
728728
return visitAppliedUse(of: operand, by: apply)
729729
}
730-
if operand.instruction is ReturnInst, !operand.value.isEscapable {
730+
if operand.instruction is ReturnInstruction, !operand.value.isEscapable {
731731
return returnedDependence(result: operand)
732732
}
733733
if operand.instruction is YieldInst, !operand.value.isEscapable {

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ private struct EscapesToValueVisitor : EscapeVisitor {
880880
if operand.value == target.value && path.projectionPath.mayOverlap(with: target.path) {
881881
return .abort
882882
}
883-
if operand.instruction is ReturnInst {
883+
if operand.instruction is ReturnInstruction {
884884
// Anything which is returned cannot escape to an instruction inside the function.
885885
return .ignore
886886
}

SwiftCompilerSources/Sources/SIL/Argument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public struct Phi {
212212
extension Phi {
213213
/// Return true of this phi is directly returned with no side effects between the phi and the return.
214214
public var isReturnValue: Bool {
215-
if let singleUse = value.uses.singleUse, let ret = singleUse.instruction as? ReturnInst,
215+
if let singleUse = value.uses.singleUse, let ret = singleUse.instruction as? ReturnInstruction,
216216
ret.parentBlock == successor {
217217
for inst in successor.instructions {
218218
if inst.mayHaveSideEffects {

SwiftCompilerSources/Sources/SIL/Function.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
121121
blocks.reversed().lazy.flatMap { $0.instructions.reversed() }
122122
}
123123

124-
public var returnInstruction: ReturnInst? {
124+
public var returnInstruction: ReturnInstruction? {
125125
for block in blocks.reversed() {
126-
if let retInst = block.terminator as? ReturnInst { return retInst }
126+
if let retInst = block.terminator as? ReturnInstruction { return retInst }
127127
}
128128
return nil
129129
}

0 commit comments

Comments
 (0)