@@ -70,6 +70,9 @@ sil @addressInt : $@convention(thin) (@in_guaranteed InlineInt) -> @lifetime(bor
70
70
sil @addressOfInt : $@convention(thin) (@in_guaranteed Int) -> @lifetime(borrow address 0) @owned Span<Int>
71
71
sil @noAddressInt : $@convention(thin) (@in_guaranteed Int) -> @lifetime(borrow 0) @owned Span<Int>
72
72
sil @useSpan : $@convention(thin) (@guaranteed Span<Int>) -> ()
73
+ sil @useRawSpan : $@convention(thin) (@guaranteed RawSpan) -> @error any Error
74
+
75
+ sil @getInlineSpan : $@convention(thin) (@in_guaranteed InlineInt) -> @lifetime(borrow address 0) @owned RawSpan
73
76
74
77
// Test returning a owned dependence on a trivial value
75
78
sil [ossa] @return_trivial_dependence : $@convention(thin) (@guaranteed C) -> @lifetime(borrow 0) @owned NE {
@@ -352,3 +355,68 @@ bb0(%0: $Int):
352
355
%18 = tuple ()
353
356
return %18
354
357
}
358
+
359
+ // Test dependence on the temporary stack address of a trivial value. computeAddressableRange must extend the lifetime
360
+ // of %tempAddr into the unreachable.
361
+ sil hidden [ossa] @testTempAddressUnreachable : $@convention(thin) (@in_guaranteed InlineInt) -> () {
362
+ bb0(%0 : $*InlineInt):
363
+ %loadArg = load [trivial] %0
364
+ %tempAddr = alloc_stack $InlineInt
365
+ store %loadArg to [trivial] %tempAddr
366
+
367
+ %f1 = function_ref @getInlineSpan : $@convention(thin) (@in_guaranteed InlineInt) -> @lifetime(borrow address 0) @owned RawSpan
368
+ %call = apply %f1(%tempAddr) : $@convention(thin) (@in_guaranteed InlineInt) -> @lifetime(borrow address 0) @owned RawSpan
369
+ %md = mark_dependence [unresolved] %call on %tempAddr
370
+
371
+ %f2 = function_ref @useRawSpan : $@convention(thin) (@guaranteed RawSpan) -> @error any Error
372
+ try_apply %f2(%md) : $@convention(thin) (@guaranteed RawSpan) -> @error any Error, normal bb1, error bb2
373
+
374
+ bb1(%void : $()):
375
+ destroy_value %md
376
+ dealloc_stack %tempAddr
377
+ %99 = tuple ()
378
+ return %99
379
+
380
+ bb2(%error : @owned $any Error):
381
+ destroy_value [dead_end] %md
382
+ unreachable
383
+ }
384
+
385
+ // Test dependence on the temporary stack address of a trivial value. computeAddressableRange must extend the lifetime
386
+ // of %tempAddr into the unreachable.
387
+ //
388
+ // Note that the computed instruction range is marked Invalid because it does not have a single dominating
389
+ // block. Nonetheless, the range still include all blocks in which the stack allocation is live, which is all we care
390
+ // about.
391
+ sil hidden [ossa] @testTempAddressNondominatedUnreachable : $@convention(thin) (@in_guaranteed InlineInt) -> () {
392
+ bb0(%0 : $*InlineInt):
393
+ cond_br undef, bb1, bb2
394
+
395
+ bb1:
396
+ br bb5
397
+
398
+ bb2:
399
+ %loadArg = load [trivial] %0
400
+ %tempAddr = alloc_stack $InlineInt
401
+ store %loadArg to [trivial] %tempAddr
402
+
403
+ %f1 = function_ref @getInlineSpan : $@convention(thin) (@in_guaranteed InlineInt) -> @lifetime(borrow address 0) @owned RawSpan
404
+ %call = apply %f1(%tempAddr) : $@convention(thin) (@in_guaranteed InlineInt) -> @lifetime(borrow address 0) @owned RawSpan
405
+ %md = mark_dependence [unresolved] %call on %tempAddr
406
+
407
+ %f2 = function_ref @useRawSpan : $@convention(thin) (@guaranteed RawSpan) -> @error any Error
408
+ try_apply %f2(%md) : $@convention(thin) (@guaranteed RawSpan) -> @error any Error, normal bb3, error bb4
409
+
410
+ bb3(%void : $()):
411
+ destroy_value %md
412
+ dealloc_stack %tempAddr
413
+ %99 = tuple ()
414
+ return %99
415
+
416
+ bb4(%error : @owned $any Error):
417
+ destroy_value [dead_end] %md
418
+ br bb5
419
+
420
+ bb5:
421
+ unreachable
422
+ }
0 commit comments