Skip to content

Commit 5387bd1

Browse files
committed
AccessEnforcementSelection: An @out parameter can be used
1 parent fbaaa75 commit 5387bd1

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
@@ -635,6 +635,10 @@ SourceAccess AccessEnforcementSelection::getSourceAccess(SILValue address) {
635635
// on the caller side.
636636
return SourceAccess::getStaticAccess();
637637

638+
case SILArgumentConvention::Indirect_Out:
639+
// We use an initialized 'out' argument as a parameter.
640+
return SourceAccess::getStaticAccess();
641+
638642
default:
639643
llvm_unreachable("Expecting an inout argument.");
640644
}

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)