Skip to content

Commit ec0026f

Browse files
committed
[NFC] AccessBase: correct initialization from pointer_to_address
AccessBase already identifies a base address as either a .global (addressor) or a .pointer. When initializing an AccessBase from a pointer_to_address, precisely identify one of these kinds of accesses, rather than simply marking it .unidentified. This used to be a special case in the AccessPathWalker. But that's not the right place to handle it.
1 parent cdb646d commit ec0026f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public enum AccessBase : CustomStringConvertible, Hashable {
103103
}
104104
case let sb as StoreBorrowInst:
105105
self = .storeBorrow(sb)
106+
case let p2a as PointerToAddressInst:
107+
if let global = p2a.resultOfGlobalAddressorCall {
108+
self = .global(global)
109+
} else {
110+
self = .pointer(p2a)
111+
}
106112
default:
107113
self = .unidentified
108114
}
@@ -528,18 +534,9 @@ private struct AccessPathWalker : AddressUseDefWalker {
528534
mutating func rootDef(address: Value, path: Path) -> WalkResult {
529535
assert(result.base == .unidentified, "rootDef should only called once")
530536
// Try identifying the address a pointer originates from
531-
if let p2ai = address as? PointerToAddressInst {
532-
if let originatingAddr = p2ai.originatingAddress {
533-
return walkUp(address: originatingAddr, path: path)
534-
} else if let global = p2ai.resultOfGlobalAddressorCall {
535-
self.result = AccessPath(base: .global(global), projectionPath: path.projectionPath)
536-
return .continueWalk
537-
} else {
538-
self.result = AccessPath(base: .pointer(p2ai), projectionPath: path.projectionPath)
539-
return .continueWalk
540-
}
537+
if let p2ai = address as? PointerToAddressInst, let originatingAddr = p2ai.originatingAddress {
538+
return walkUp(address: originatingAddr, path: path)
541539
}
542-
543540
let base = AccessBase(baseAddress: address)
544541
self.result = AccessPath(base: base, projectionPath: path.projectionPath)
545542
return .continueWalk

0 commit comments

Comments
 (0)