File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -1701,6 +1701,13 @@ template <typename ImplClass>
1701
1701
void SILCloner<ImplClass>::visitUnmanagedAutoreleaseValueInst(
1702
1702
UnmanagedAutoreleaseValueInst *Inst) {
1703
1703
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
1704
+ if (!getBuilder ().hasOwnership ()) {
1705
+ return recordClonedInstruction (Inst, getBuilder ().createAutoreleaseValue (
1706
+ getOpLocation (Inst->getLoc ()),
1707
+ getOpValue (Inst->getOperand ()),
1708
+ Inst->getAtomicity ()));
1709
+ }
1710
+
1704
1711
recordClonedInstruction (Inst, getBuilder ().createUnmanagedAutoreleaseValue (
1705
1712
getOpLocation (Inst->getLoc ()),
1706
1713
getOpValue (Inst->getOperand ()),
Original file line number Diff line number Diff line change
1
+ // RUN: %target-sil-opt -enable-sil-verify-all %s -mandatory-inlining -enable-sil-ownership | %FileCheck %s
2
+
3
+ // REQUIRES: objc_interop
4
+
5
+ sil_stage raw
6
+
7
+ import Builtin
8
+ import Swift
9
+ import ObjectiveC
10
+
11
+ //////////////////
12
+ // Declarations //
13
+ //////////////////
14
+
15
+ class Klass : NSObject {}
16
+
17
+ ///////////
18
+ // Tests //
19
+ ///////////
20
+
21
+ // Test out functionality that we use to work around weird semantics of
22
+ // destructors.
23
+ sil [ossa] [transparent] @unmanaged_rr_callee : $@convention(thin) (@guaranteed Klass) -> () {
24
+ bb0(%0 : @guaranteed $Klass):
25
+ unmanaged_autorelease_value %0 : $Klass
26
+ %9999 = tuple()
27
+ return %9999 : $()
28
+ }
29
+
30
+ // CHECK-LABEL: sil @unmanaged_rr_caller : $@convention(thin) (@guaranteed Klass) -> () {
31
+ // CHECK: bb0([[ARG:%.*]] :
32
+ // CHECK-NEXT: autorelease_value [[ARG]]
33
+ // CHECK-NEXT: tuple
34
+ // CHECK-NEXT: tuple
35
+ // CHECK-NEXT: return
36
+ // CHECK: } // end sil function 'unmanaged_rr_caller'
37
+ sil @unmanaged_rr_caller : $@convention(thin) (@guaranteed Klass) -> () {
38
+ bb0(%0 : $Klass):
39
+ %1 = function_ref @unmanaged_rr_callee : $@convention(thin) (@guaranteed Klass) -> ()
40
+ apply %1(%0) : $@convention(thin) (@guaranteed Klass) -> ()
41
+ %9999 = tuple()
42
+ return %9999 : $()
43
+ }
You can’t perform that action at this time.
0 commit comments