File tree Expand file tree Collapse file tree 3 files changed +62
-3
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 3 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -985,13 +985,12 @@ RegionAnalysisValueMap::getUnderlyingTrackedValueHelperAddress(
985985 // occur in the underlying DenseMap that backs getUnderlyingTrackedValue()
986986 // if we insert another entry into the DenseMap.
987987 if (!visitor.value )
988- return UnderlyingTrackedValueInfo (
989- getUnderlyingTrackedValueHelperObject (base));
988+ return UnderlyingTrackedValueInfo (getUnderlyingTrackedValueHelper (base));
990989
991990 // TODO: Should we us the base or value from
992991 // getUnderlyingTrackedValueHelperObject as our base?
993992 return UnderlyingTrackedValueInfo (
994- visitor.value , getUnderlyingTrackedValueHelperObject (base).value );
993+ visitor.value , getUnderlyingTrackedValueHelper (base).value );
995994 }
996995
997996 // Otherwise, we return the actorIsolation that our visitor found.
Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ class NonSendableKlassWithState {
5656
5757actor Custom {}
5858
59+ enum MyEnum<T> {
60+ case none
61+ indirect case some(NonSendableKlass)
62+ case some2(T)
63+ }
64+
5965sil @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
6066sil @useNonSendableKlass : $@convention(thin) (@guaranteed NonSendableKlass) -> ()
6167sil @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
@@ -639,4 +645,40 @@ bb0(%0 : @owned $Struct2):
639645 dealloc_stack %1
640646 %9999 = tuple ()
641647 return %9999 : $()
648+ }
649+
650+ // CHECK-LABEL: begin running test 1 of 1 on indirect_enum_load_take: sil_regionanalysis_underlying_tracked_value with: @trace[0]
651+ // CHECK: TrackableValue. State: TrackableValueState[id: 0][is_no_alias: yes][is_sendable: no][region_value_kind: disconnected].
652+ // CHECK: Rep Value: %1 = alloc_stack $MyEnum<T>
653+ // CHECK: end running test 1 of 1 on indirect_enum_load_take: sil_regionanalysis_underlying_tracked_value with: @trace[0]
654+ sil [ossa] @indirect_enum_load_take : $@convention(thin) @async <T> (@in_guaranteed MyEnum<T>) -> () {
655+ bb0(%0 : $*MyEnum<T>):
656+ specify_test "sil_regionanalysis_underlying_tracked_value @trace[0]"
657+ %1 = alloc_stack $MyEnum<T>
658+ copy_addr %0 to [init] %1
659+ switch_enum_addr %1, case #MyEnum.some!enumelt: bb1, default bb2
660+
661+ bb1:
662+ %2 = unchecked_take_enum_data_addr %1, #MyEnum.some!enumelt
663+ %3 = load [take] %2
664+ %4 = project_box %3, 0
665+ %5 = load_borrow %4
666+ %6 = copy_value %5
667+ debug_value [trace] %5
668+ %7 = move_value [var_decl] %6
669+ debug_value %5, let, name "x"
670+ destroy_value %7
671+ end_borrow %5
672+ destroy_value %3
673+ dealloc_stack %1
674+ br bb3
675+
676+ bb2:
677+ destroy_addr %1
678+ dealloc_stack %1
679+ br bb3
680+
681+ bb3:
682+ %9999 = tuple ()
683+ return %9999 : $()
642684}
Original file line number Diff line number Diff line change @@ -93,6 +93,12 @@ struct SendableGenericStruct : Sendable {
9393 var x = SendableKlass ( )
9494}
9595
96+ enum MyEnum < T> {
97+ case none
98+ indirect case some( NonSendableKlass )
99+ case more( T )
100+ }
101+
96102////////////////////////////
97103// MARK: Actor Self Tests //
98104////////////////////////////
@@ -2027,3 +2033,15 @@ func testIsolatedParamInference() {
20272033 }
20282034 }
20292035}
2036+
2037+ // We used to crash on this since we were not looking finding underlying objects
2038+ // hard enough.
2039+ func indirectEnumTestCase< T> ( _ e: MyEnum < T > ) async -> Bool {
2040+ switch e {
2041+ case . some( let x) :
2042+ _ = x
2043+ return true
2044+ default :
2045+ return false
2046+ }
2047+ }
You can’t perform that action at this time.
0 commit comments