Skip to content

Commit 2066826

Browse files
authored
Merge pull request #82421 from gottesmm/pr-0768c1bbd539bf7437d416ffb08cc970b9b96185
[region-isolation] Fix crash due to missing visitVectorBaseAddrInst case
2 parents be6669b + 660263c commit 2066826

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,16 @@ struct AddressBaseComputingVisitor
141141
return SILValue();
142142
}
143143

144-
SILValue visitNonAccess(SILValue) { return SILValue(); }
144+
SILValue visitNonAccess(SILValue value) {
145+
// For now since it is late in 6.2, work around vector base addr not being
146+
// treated as a projection.
147+
if (auto *v = dyn_cast<VectorBaseAddrInst>(value)) {
148+
isProjectedFromAggregate = true;
149+
return v->getOperand();
150+
}
151+
152+
return SILValue();
153+
}
145154

146155
SILValue visitPhi(SILPhiArgument *phi) {
147156
llvm_unreachable("Should never hit this");
@@ -312,6 +321,7 @@ static bool isStaticallyLookThroughInst(SILInstruction *inst) {
312321
case SILInstructionKind::UncheckedEnumDataInst:
313322
case SILInstructionKind::StructElementAddrInst:
314323
case SILInstructionKind::TupleElementAddrInst:
324+
case SILInstructionKind::VectorBaseAddrInst:
315325
return true;
316326
case SILInstructionKind::MoveValueInst:
317327
// Look through if it isn't from a var decl.

test/Concurrency/regionanalysis_trackable_value.sil

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,4 +681,45 @@ bb2:
681681
bb3:
682682
%9999 = tuple ()
683683
return %9999 : $()
684-
}
684+
}
685+
686+
// CHECK-LABEL: begin running test 1 of 1 on alloc_stack_inline_array_sendable: sil_regionanalysis_underlying_tracked_value with: @trace[0]
687+
// CHECK: TrackableValue. State: TrackableValueState[id: 0][is_no_alias: no][is_sendable: yes][region_value_kind: disconnected].
688+
// CHECK: Rep Value: %2 = vector_base_addr %1
689+
// CHECK: end running test 1 of 1 on alloc_stack_inline_array_sendable: sil_regionanalysis_underlying_tracked_value with: @trace[0]
690+
sil [ossa] @alloc_stack_inline_array_sendable : $@convention(thin) () -> () {
691+
bb0:
692+
specify_test "sil_regionanalysis_underlying_tracked_value @trace[0]"
693+
%0 = alloc_stack $InlineArray<1, UInt8>
694+
%1 = struct_element_addr %0: $*InlineArray<1, UInt8>, #InlineArray._storage
695+
%2 = vector_base_addr %1 : $*Builtin.FixedArray<1, UInt8>
696+
%3 = integer_literal $Builtin.Int8, 0
697+
%4 = struct $UInt8 (%3)
698+
store %4 to [trivial] %2
699+
%6 = load [trivial] %0
700+
dealloc_stack %0
701+
debug_value [trace] %2
702+
703+
%7 = tuple ()
704+
return %7 : $()
705+
}
706+
707+
// CHECK-LABEL: begin running test 1 of 1 on alloc_stack_inline_array_nonsendable: sil_regionanalysis_underlying_tracked_value with: @trace[0]
708+
// CHECK: TrackableValue. State: TrackableValueState[id: 0][is_no_alias: yes][is_sendable: no][region_value_kind: disconnected].
709+
// CHECK: Rep Value: %1 = alloc_stack $InlineArray
710+
// CHECK: end running test 1 of 1 on alloc_stack_inline_array_nonsendable: sil_regionanalysis_underlying_tracked_value with: @trace[0]
711+
sil [ossa] @alloc_stack_inline_array_nonsendable : $@convention(thin) (@owned NonSendableKlass) -> () {
712+
bb0(%arg : @owned $NonSendableKlass):
713+
specify_test "sil_regionanalysis_underlying_tracked_value @trace[0]"
714+
%0 = alloc_stack $InlineArray<1, NonSendableKlass>
715+
%1 = struct_element_addr %0: $*InlineArray<1, NonSendableKlass>, #InlineArray._storage
716+
%2 = vector_base_addr %1 : $*Builtin.FixedArray<1, NonSendableKlass>
717+
store %arg to [init] %2
718+
%6 = load [take] %0
719+
destroy_value %6
720+
dealloc_stack %0
721+
debug_value [trace] %2
722+
723+
%7 = tuple ()
724+
return %7 : $()
725+
}

test/Concurrency/transfernonsendable_rbi_result.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -swift-version 6 -parse-as-library %s -emit-sil -o /dev/null -verify
1+
// 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
22

33
// REQUIRES: asserts
44
// REQUIRES: concurrency
@@ -135,3 +135,8 @@ func testGenericResults() async {
135135
let _: NonSendable = await mainActorGenericReturnNonSendable()
136136
// expected-error @-1 {{non-Sendable 'NonSendable'-typed result can not be returned from main actor-isolated global function 'mainActorGenericReturnNonSendable()' to nonisolated context}}
137137
}
138+
139+
// https://github.com/swiftlang/swift/issues/81534
140+
func testInlineArray() {
141+
let _: InlineArray<_, UInt8> = [0]
142+
}

0 commit comments

Comments
 (0)