Skip to content

Commit 1d27a04

Browse files
Merge pull request swiftlang#14526 from aschwaighofer/indirect_out_accessenforcementselection
AccessEnforcementSelection: An @out parameter can be used
2 parents f9593a9 + 5387bd1 commit 1d27a04

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/SILOptimizer/Mandatory/AccessEnforcementSelection.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ SourceAccess AccessEnforcementSelection::getSourceAccess(SILValue address) {
647647
// on the caller side.
648648
return SourceAccess::getStaticAccess();
649649

650+
case SILArgumentConvention::Indirect_Out:
651+
// We use an initialized 'out' argument as a parameter.
652+
return SourceAccess::getStaticAccess();
653+
650654
default:
651655
llvm_unreachable("Expecting an inout argument.");
652656
}

test/SILOptimizer/access_enforcement_selection.sil

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,11 @@ sil @borrowClosure : $@convention(thin) () -> () {
220220
%empty = tuple ()
221221
return %empty : $()
222222
}
223+
224+
sil @dontAssert : $@convention(thin) (Builtin.Int64) -> (@out Builtin.Int64) {
225+
bb0(%0 : @trivial $*Builtin.Int64, %1 : @trivial $Builtin.Int64):
226+
store %1 to [trivial] %0 : $*Builtin.Int64
227+
%f = function_ref @closureCapturingByStorageAddress : $@convention(thin) (@inout_aliasable Builtin.Int64) -> ()
228+
%closure = partial_apply %f(%0) : $@convention(thin) (@inout_aliasable Builtin.Int64) -> ()
229+
unreachable
230+
}

0 commit comments

Comments
 (0)