Skip to content

[region-isolation]fix crash due to missing VectorBaseAddrInst case #81591

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lib/SILOptimizer/Analysis/RegionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ static bool isStaticallyLookThroughInst(SILInstruction *inst) {
case SILInstructionKind::UncheckedEnumDataInst:
case SILInstructionKind::StructElementAddrInst:
case SILInstructionKind::TupleElementAddrInst:
case SILInstructionKind::VectorBaseAddrInst:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you need to add a visitor case below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it was already added below. The best way to make sure this does not happen in the future is for people to add a test in https://github.com/swiftlang/swift/blob/main/test/Concurrency/regionanalysis_trackable_value.sil. Can you add a test case for this there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gottesmm

Thank you for the advice.

I have added a test based on the debug log, but it does not reproduce the issue.

Could you suggest what kind of test I should add?

return true;
case SILInstructionKind::MoveValueInst:
// Look through if it isn't from a var decl.
Expand Down
23 changes: 22 additions & 1 deletion test/Concurrency/regionanalysis_trackable_value.sil
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,25 @@ bb2:
bb3:
%9999 = tuple ()
return %9999 : $()
}
}

// CHECK-LABEL: begin running test 1 of 1 on allock_stack_inline_array_test: sil_regionanalysis_underlying_tracked_value with: @trace[0]
// CHECK: TrackableValue. State: TrackableValueState[id: 0][is_no_alias: no][is_sendable: yes][region_value_kind: disconnected].
// CHECK: Rep Value: %2 = vector_base_addr %1
// CHECK: end running test 1 of 1 on allock_stack_inline_array_test: sil_regionanalysis_underlying_tracked_value with: @trace[0]
sil [ossa] @allock_stack_inline_array_test : $@convention(thin) () -> () {
bb0:
specify_test "sil_regionanalysis_underlying_tracked_value @trace[0]"
%0 = alloc_stack $InlineArray<1, UInt8>
%1 = struct_element_addr %0: $*InlineArray<1, UInt8>, #InlineArray._storage
%2 = vector_base_addr %1 : $*Builtin.FixedArray<1, UInt8>
%3 = integer_literal $Builtin.Int8, 0
%4 = struct $UInt8 (%3)
store %4 to [trivial] %2
%6 = load [trivial] %0
dealloc_stack %0
debug_value [trace] %2

%7 = tuple ()
return %7 : $()
}
7 changes: 6 additions & 1 deletion test/Concurrency/transfernonsendable_rbi_result.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -swift-version 6 -parse-as-library %s -emit-sil -o /dev/null -verify
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -swift-version 6 -disable-availability-checking -parse-as-library %s -emit-sil -o /dev/null -verify

// REQUIRES: asserts
// REQUIRES: concurrency
Expand Down Expand Up @@ -135,3 +135,8 @@ func testGenericResults() async {
let _: NonSendable = await mainActorGenericReturnNonSendable()
// expected-error @-1 {{non-Sendable 'NonSendable'-typed result can not be returned from main actor-isolated global function 'mainActorGenericReturnNonSendable()' to nonisolated context}}
}

// https://github.com/swiftlang/swift/issues/81534
func testInlineArray() {
let _: InlineArray<_, UInt8> = [0]
}