Skip to content

Allow a borrowed address to be passed as in_guaranteed arg in partial_apply [on_stack] only #34736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/SIL/Verifier/LoadBorrowImmutabilityChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ bool GatherWritesVisitor::visitUse(Operand *op, AccessUseType useTy) {

if (auto *pa = dyn_cast<PartialApplyInst>(user)) {
auto argConv = ApplySite(user).getArgumentConvention(*op);
if (argConv == SILArgumentConvention::Indirect_In_Guaranteed) {
if (pa->isOnStack() &&
argConv == SILArgumentConvention::Indirect_In_Guaranteed) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %target-sil-opt -enable-sil-verify-all -inline %s -o /dev/null
// RUN: %target-sil-opt -enable-sil-verify-all -inline %s -verify-continue-on-failure=true -o /dev/null 2>&1 | %FileCheck %s
// REQUIRES: asserts

// Tests here are patterns we should not consider as broken

Expand Down Expand Up @@ -37,6 +38,7 @@ bb0(%0 : $*WrapperStruct):
return %res : $()
}

// CHECK-NOT: Function: 'caller1'
sil [ossa] @caller1 : $@convention(thin) (@owned WrapperStruct) -> () {
bb0(%0 : @owned $WrapperStruct):
%stk = alloc_stack $WrapperStruct
Expand All @@ -49,6 +51,9 @@ bb0(%0 : @owned $WrapperStruct):
return %res : $()
}

// CHECK-LABEL: Begin Error in function caller2
// CHECK: SIL verification failed: Found load borrow that is invalidated by a local write?!: loadBorrowImmutabilityAnalysis.isImmutable(LBI)
// CHECK-LABEL: End Error in function caller2
sil [ossa] @caller2 : $@convention(thin) (@owned WrapperStruct) -> () {
bb0(%0 : @owned $WrapperStruct):
%stk = alloc_stack $WrapperStruct
Expand Down