@@ -22,6 +22,13 @@ case some(T)
22
22
case none
23
23
}
24
24
25
+ protocol Error {}
26
+
27
+ struct NativeObjectPair {
28
+ var obj1 : Builtin.NativeObject
29
+ var obj2 : Builtin.NativeObject
30
+ }
31
+
25
32
class SuperKlass {
26
33
func doSomething()
27
34
}
@@ -485,3 +492,35 @@ bb0(%0 : @guaranteed $ClassProtConformingRef, %1 : @owned $ClassProtConformingRe
485
492
%5 = tuple(%3 : $ClassProt, %4 : $ClassProt)
486
493
return %5 : $(ClassProt, ClassProt)
487
494
}
495
+
496
+ sil [ossa] @eliminate_copy_try_apple_callee : $@convention(thin) (@owned Builtin.NativeObject) -> @error Error {
497
+ entry(%0 : @owned $Builtin.NativeObject):
498
+ %9999 = tuple()
499
+ return %9999 : $()
500
+ }
501
+
502
+
503
+ // CHECK-LABEL: Function: 'use_after_free_consume_in_same_block'
504
+ // CHECK: Found use after free due to unvisited non lifetime ending uses?!
505
+ // CHECK: Value: %3 = copy_value %2 : $Builtin.NativeObject
506
+ // CHECK: Remaining Users:
507
+ // CHECK: User: %10 = apply %7(%3) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
508
+ sil [ossa] @use_after_free_consume_in_same_block : $@convention(thin) (@owned NativeObjectPair) -> @error Error {
509
+ bb0(%0 : @owned $NativeObjectPair):
510
+ %1 = begin_borrow %0 : $NativeObjectPair
511
+ %2 = struct_extract %1 : $NativeObjectPair, #NativeObjectPair.obj1
512
+ %3 = copy_value %2 : $Builtin.NativeObject
513
+ end_borrow %1 : $NativeObjectPair
514
+ destroy_value %0 : $NativeObjectPair
515
+ %4 = function_ref @eliminate_copy_try_apple_callee : $@convention(thin) (@owned Builtin.NativeObject) -> @error Error
516
+ %5 = function_ref @guaranteed_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
517
+ try_apply %4(%3) : $@convention(thin) (@owned Builtin.NativeObject) -> @error Error, normal bb1, error bb2
518
+
519
+ bb1(%errorEmptyTup: $()):
520
+ apply %5(%3) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
521
+ %9999 = tuple()
522
+ return %9999 : $()
523
+
524
+ bb2(%error : @owned $Error):
525
+ throw %error : $Error
526
+ }
0 commit comments