@@ -192,8 +192,7 @@ extension AccessBase {
192
192
/// with the initialized address. This does not guarantee that all
193
193
/// uses of that address are dominated by the store or even that the
194
194
/// store is a direct use of `address`.
195
- func findSingleInitializer( _ context: some Context )
196
- -> ( initialAddress: Value , initializingStore: Instruction ) ? {
195
+ func findSingleInitializer( _ context: some Context ) -> ( initialAddress: Value , initializingStore: Instruction ) ? {
197
196
let baseAddr : Value
198
197
switch self {
199
198
case let . stack( allocStack) :
@@ -206,15 +205,7 @@ extension AccessBase {
206
205
default :
207
206
return nil
208
207
}
209
- var walker = AddressInitializationWalker ( context: context)
210
- if walker. walkDownUses ( ofAddress: baseAddr, path: SmallProjectionPath ( ) )
211
- == . abortWalk {
212
- return nil
213
- }
214
- guard let initializingStore = walker. initializingStore else {
215
- return nil
216
- }
217
- return ( initialAddress: baseAddr, initializingStore: initializingStore)
208
+ return AddressInitializationWalker . findSingleInitializer ( ofAddress: baseAddr, context: context)
218
209
}
219
210
}
220
211
@@ -223,6 +214,9 @@ extension AccessBase {
223
214
// Implements AddressUseVisitor to guarantee that we can't miss any
224
215
// stores. This separates escapingAddressUse from leafAddressUse.
225
216
//
217
+ // Main entry point:
218
+ // static func findSingleInitializer(ofAddress: Value, context: some Context)
219
+ //
226
220
// TODO: Make AddressDefUseWalker always conform to AddressUseVisitor once we're
227
221
// ready to debug changes to escape analysis etc...
228
222
//
@@ -249,6 +243,19 @@ struct AddressInitializationWalker: AddressDefUseWalker, AddressUseVisitor {
249
243
var isProjected = false
250
244
var initializingStore : Instruction ?
251
245
246
+ static func findSingleInitializer( ofAddress baseAddr: Value , context: some Context )
247
+ -> ( initialAddress: Value , initializingStore: Instruction ) ? {
248
+
249
+ var walker = AddressInitializationWalker ( context: context)
250
+ if walker. walkDownUses ( ofAddress: baseAddr, path: SmallProjectionPath ( ) ) == . abortWalk {
251
+ return nil
252
+ }
253
+ guard let initializingStore = walker. initializingStore else {
254
+ return nil
255
+ }
256
+ return ( initialAddress: baseAddr, initializingStore: initializingStore)
257
+ }
258
+
252
259
private mutating func setInitializer( instruction: Instruction ) -> WalkResult {
253
260
// An initializer must be unique and store the full value.
254
261
if initializingStore != nil || isProjected {
0 commit comments