Skip to content

Commit afda645

Browse files
committed
Improve LocalVariableAccessInfo: recognize more full-assignments.
Ignore marker instructions for the purpose of determining whether a store is a full assignment: %a = alloc_stack %m = moveonlywrapper_to_copyable_addr %a store %0 to [init] %m // <=== full assignemt
1 parent 6b2fb2e commit afda645

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,18 @@ class LocalVariableAccessInfo: CustomStringConvertible {
197197
}
198198

199199
var description: String {
200-
return "full-assign: \(_isFullyAssigned == nil ? "unknown" : String(describing: _isFullyAssigned!)) "
200+
return "full-assign: \(_isFullyAssigned == nil ? "unknown" : String(describing: _isFullyAssigned!)), "
201201
+ "\(access)"
202202
}
203203

204204
// Does this address correspond to the local variable's base address? Any writes to this address will be a full
205205
// assignment. This should match any instructions that the LocalVariableAccessMap initializer below recognizes as an
206206
// allocation.
207207
static private func isBase(address: Value) -> Bool {
208-
switch address {
209-
case is AllocBoxInst, is AllocStackInst, is BeginAccessInst:
210-
return true
211-
default:
212-
return false
213-
}
208+
// TODO: create an API alternative to 'accessPath' that bails out on the first path component and succeeds on the
209+
// first begin_access.
210+
let path = address.accessPath
211+
return path.base.isLocal && path.projectionPath.isEmpty
214212
}
215213
}
216214

0 commit comments

Comments
 (0)