@@ -279,7 +279,7 @@ extension AccessBase {
279279 default :
280280 return nil
281281 }
282- return AddressInitializationWalker . findSingleInitializer ( ofAddress: baseAddr, context : context)
282+ return AddressInitializationWalker . findSingleInitializer ( ofAddress: baseAddr, requireFullyAssigned : . value , context)
283283 }
284284}
285285
@@ -311,25 +311,29 @@ extension AccessBase {
311311// modification of memory.
312312struct AddressInitializationWalker : AddressDefUseWalker , AddressUseVisitor {
313313 let baseAddress : Value
314+ let requireFullyAssigned : IsFullyAssigned
314315 let context : any Context
315316
316317 var walkDownCache = WalkerCache < SmallProjectionPath > ( )
317318
318319 var isProjected = false
319320 var initializer : AccessBase . Initializer ?
320321
321- static func findSingleInitializer( ofAddress baseAddr: Value , context: some Context )
322+ static func findSingleInitializer( ofAddress baseAddr: Value , requireFullyAssigned: IsFullyAssigned ,
323+ _ context: some Context )
322324 -> AccessBase . Initializer ? {
323325
324- var walker = AddressInitializationWalker ( baseAddress: baseAddr, context)
326+ var walker = AddressInitializationWalker ( baseAddress: baseAddr, requireFullyAssigned , context)
325327 if walker. walkDownUses ( ofAddress: baseAddr, path: SmallProjectionPath ( ) ) == . abortWalk {
326328 return nil
327329 }
328330 return walker. initializer
329331 }
330332
331- private init ( baseAddress: Value , _ context: some Context ) {
333+ private init ( baseAddress: Value , _ requireFullyAssigned: IsFullyAssigned , _ context: some Context ) {
334+ assert ( requireFullyAssigned != . no)
332335 self . baseAddress = baseAddress
336+ self . requireFullyAssigned = requireFullyAssigned
333337 self . context = context
334338 if let arg = baseAddress as? FunctionArgument {
335339 assert ( !arg. convention. isIndirectIn, " @in arguments cannot be initialized " )
@@ -392,7 +396,15 @@ extension AddressInitializationWalker {
392396
393397 mutating func appliedAddressUse( of operand: Operand , by apply: FullApplySite )
394398 -> WalkResult {
395- if operand. isAddressInitialization {
399+ switch apply. fullyAssigns ( operand: operand) {
400+ case . no:
401+ break
402+ case . lifetime:
403+ if requireFullyAssigned == . value {
404+ break
405+ }
406+ fallthrough
407+ case . value:
396408 return setInitializer ( instruction: operand. instruction)
397409 }
398410 guard let convention = apply. convention ( of: operand) else {
0 commit comments