Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[semantic-sil] Add special unmanaged_{retain,release}_value instructi…
…ons for unpaired retain/release operations in semantic sil. The reason why I am introducing special instructions is so I can maintain the qualified ownership API wedge in between qualified SIL and the rest of the ARC instructions that are pervasively used in the compiler. These instructions in the future /could/ be extended to just take @sil_unmanaged operands directly, but I want to maintain flexibility to take regular non-trivial operands in the short term. rdar://29791263
- Loading branch information
Showing
17 changed files
with
214 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil %s | ||
// RUN: %target-sil-opt %s | ||
|
||
import Swift | ||
import Builtin | ||
|
||
class C {} | ||
|
||
sil @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () { | ||
bb0(%1 : $*Optional<U>): | ||
%17 = load %1 : $*Optional<U> | ||
%18 = ref_to_unmanaged %17 : $Optional<U> to $@sil_unmanaged Optional<U> | ||
%6 = tuple () | ||
return %6 : $() | ||
bb0(%0 : $*Optional<U>): | ||
%1 = load [copy] %0 : $*Optional<U> | ||
%2 = ref_to_unmanaged %1 : $Optional<U> to $@sil_unmanaged Optional<U> | ||
%3 = unmanaged_to_ref %2 : $@sil_unmanaged Optional<U> to $Optional<U> | ||
destroy_value %1 : $Optional<U> | ||
%9999 = tuple () | ||
return %9999 : $() | ||
} | ||
|
||
sil @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () { | ||
bb0(%0 : $@sil_unmanaged Optional<C>): | ||
%1 = unmanaged_to_ref %0 : $@sil_unmanaged Optional<C> to $Optional<C> | ||
unmanaged_retain_value %1 : $Optional<C> | ||
unmanaged_release_value %1 : $Optional<C> | ||
%9999 = tuple() | ||
return %9999 : $() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// First parse this and then emit a *.sib. Then read in the *.sib, then recreate | ||
// RUN: rm -rfv %t | ||
// RUN: mkdir %t | ||
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name unmanaged | ||
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.2.sib -module-name unmanaged | ||
// RUN: %target-sil-opt %t/tmp.2.sib -module-name unmanaged | %FileCheck %s | ||
|
||
import Swift | ||
import Builtin | ||
|
||
class C {} | ||
|
||
// CHECK-LABEL: sil @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () { | ||
// CHECK: bb0([[ARG:%.*]] : $@sil_unmanaged Optional<C>): | ||
// CHECK: [[REF:%.*]] = unmanaged_to_ref [[ARG]] : $@sil_unmanaged Optional<C> to $Optional<C> | ||
// CHECK: unmanaged_retain_value [[REF]] | ||
// CHECK: unmanaged_release_value [[REF]] | ||
sil @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () { | ||
bb0(%0 : $@sil_unmanaged Optional<C>): | ||
%1 = unmanaged_to_ref %0 : $@sil_unmanaged Optional<C> to $Optional<C> | ||
unmanaged_retain_value %1 : $Optional<C> | ||
unmanaged_release_value %1 : $Optional<C> | ||
%9999 = tuple() | ||
return %9999 : $() | ||
} | ||
|
||
// CHECK-LABEL: sil @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () { | ||
// CHECK: bb0([[ARG:%.*]] : $*Optional<U>): | ||
// CHECK: [[LOADED_ARG:%.*]] = load [copy] [[ARG]] | ||
// CHECK: [[UNMANGED_LOADED_ARG:%.*]] = ref_to_unmanaged [[LOADED_ARG]] : $Optional<U> to $@sil_unmanaged Optional<U> | ||
// CHECK: {{%.*}} = unmanaged_to_ref [[UNMANGED_LOADED_ARG]] : $@sil_unmanaged Optional<U> to $Optional<U> | ||
// CHECK: destroy_value [[LOADED_ARG]] | ||
sil @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () { | ||
bb0(%0 : $*Optional<U>): | ||
%1 = load [copy] %0 : $*Optional<U> | ||
%2 = ref_to_unmanaged %1 : $Optional<U> to $@sil_unmanaged Optional<U> | ||
%3 = unmanaged_to_ref %2 : $@sil_unmanaged Optional<U> to $Optional<U> | ||
destroy_value %1 : $Optional<U> | ||
%9999 = tuple () | ||
return %9999 : $() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters