Skip to content

Commit daea8dc

Browse files
authored
Merge pull request #72358 from gottesmm/pr-27b1ff531d49e84b63276fa4313f5aba2de9abf6
[region-isolation] Fix crasher.
2 parents 5022da8 + c2c4f13 commit daea8dc

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,8 +3345,8 @@ TrackableValue RegionAnalysisValueMap::getTrackableValue(
33453345

33463346
auto storage = AccessStorageWithBase::compute(svi->getOperand(0));
33473347
if (storage.storage) {
3348-
if (isa<RefElementAddrInst>(storage.base)) {
3349-
auto *nomDecl = storage.storage.getRoot()
3348+
if (auto *reai = dyn_cast<RefElementAddrInst>(storage.base)) {
3349+
auto *nomDecl = reai->getOperand()
33503350
->getType()
33513351
.getNominalOrBoundGenericNominal();
33523352
iter.first->getSecond().mergeIsolationRegionInfo(

test/Concurrency/transfernonsendable.sil

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import _Concurrency
1919
// MARK: Declarations //
2020
////////////////////////
2121

22+
class Klass {}
23+
2224
class NonSendableKlass {
25+
var klass: Klass
26+
2327
func asyncCall() async
2428
}
2529

@@ -353,3 +357,21 @@ bb0:
353357
return %38 : $()
354358
}
355359

360+
// Make sure that when we process the following sil we do not crash.
361+
//
362+
// We previously crashed since we used the base of the storage instead of the
363+
// operand of the root (the ref_element_addr)
364+
sil [ossa] @test_ref_element_addr_with_different_storage_no_crash : $@convention(method) <Self where Self : NonSendableKlass> (@guaranteed Self) -> () {
365+
bb0(%0 : @guaranteed $Self):
366+
%1 = copy_value %0 : $Self
367+
%2 = upcast %1 : $Self to $NonSendableKlass
368+
%3 = begin_borrow %2 : $NonSendableKlass
369+
%4 = ref_element_addr [immutable] %3 : $NonSendableKlass, #NonSendableKlass.klass
370+
%5 = load [copy] %4 : $*Klass
371+
destroy_value %5 : $Klass
372+
end_borrow %3 : $NonSendableKlass
373+
destroy_value %2 : $NonSendableKlass
374+
%9999 = tuple ()
375+
return %9999 : $()
376+
}
377+

0 commit comments

Comments
 (0)