Skip to content

Commit 1cdf9d5

Browse files
committed
LifetimeDefUseWalker handles inherited dependencies.
This is needed when we don't insert mark_dependence.
1 parent ade2ed6 commit 1cdf9d5

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,32 @@ extension LifetimeDependenceDefUseWalker {
10531053
if let conv = apply.convention(of: operand), conv.isIndirectOut {
10541054
return leafUse(of: operand)
10551055
}
1056-
10571056
if apply.isCallee(operand: operand) {
10581057
return leafUse(of: operand)
10591058
}
1059+
if let dep = apply.resultDependence(on: operand),
1060+
dep == .inherit {
1061+
// Operand is nonescapable and passed as a call argument. If the
1062+
// result inherits its lifetime, then consider any nonescapable
1063+
// result value to be a dependent use.
1064+
//
1065+
// If the lifetime dependence is scoped, then we can ignore it
1066+
// because a mark_dependence [nonescaping] represents the
1067+
// dependence.
1068+
if let result = apply.singleDirectResult, !result.type.isEscapable {
1069+
if dependentUse(of: operand, into: result) == .abortWalk {
1070+
return .abortWalk
1071+
}
1072+
}
1073+
for resultAddr in apply.indirectResultOperands
1074+
where !resultAddr.value.type.isEscapable {
1075+
if visitStoredUses(of: operand, into: resultAddr.value) == .abortWalk {
1076+
return .abortWalk
1077+
}
1078+
}
1079+
}
1080+
// Regardless of lifetime dependencies, consider the operand to be
1081+
// use for the duration of the call.
10601082
if apply is BeginApplyInst {
10611083
return scopedAddressUse(of: operand)
10621084
}

0 commit comments

Comments
 (0)