Skip to content

Commit 198f1af

Browse files
committed
Add LifetimeDependence utilities
- LifetimeDependence - VariableIntroducerUseDefWalker - LifetimeDependenceUseDefWalker - LifetimeDependenceDefUseWalker
1 parent ba9ad08 commit 198f1af

File tree

10 files changed

+1263
-469
lines changed

10 files changed

+1263
-469
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ swift_compiler_sources(Optimizer
1313
Devirtualization.swift
1414
EscapeUtils.swift
1515
ForwardingUtils.swift
16+
LifetimeDependenceUtils.swift
1617
OptUtils.swift
1718
OwnershipLiveness.swift
1819
SSAUpdater.swift

SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ extension ForwardingDefUseWalker {
252252
if !needWalk(for: value) { return .continueWalk }
253253

254254
var hasUse = false
255-
for operand in value.uses where !operand.isTypeDependent {
256-
if walkDown(operand: operand) == .abortWalk {
255+
for use in value.uses where !use.isTypeDependent {
256+
if walkDown(operand: use) == .abortWalk {
257257
return .abortWalk
258258
}
259259
hasUse = true
@@ -270,7 +270,12 @@ extension ForwardingDefUseWalker {
270270

271271
mutating func walkDownDefault(forwarding operand: Operand) -> WalkResult {
272272
if let inst = operand.instruction as? ForwardingInstruction {
273-
return inst.forwardedResults.walk { walkDownUses(of: $0, using: operand) }
273+
let singleOper = inst.singleForwardedOperand
274+
if singleOper == nil || singleOper! == operand {
275+
return inst.forwardedResults.walk {
276+
walkDownUses(of: $0, using: operand)
277+
}
278+
}
274279
}
275280
if let phi = Phi(using: operand) {
276281
return walkDownUses(of: phi.value, using: operand)

0 commit comments

Comments
 (0)