Skip to content

Commit 8464b97

Browse files
committed
AliasAnalysis: workaround a bug in the move-only checker
This is a workaround for a bug in the move-only checker: rdar://151841926. The move-only checker sometimes inserts destroy_addr within read-only static access scopes. Therefore don't consider static access scopes as immutable scopes.
1 parent 85228f2 commit 8464b97

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,14 @@ private enum ImmutableScope {
622622
if beginAccess.isUnsafe {
623623
return nil
624624
}
625+
626+
// This is a workaround for a bug in the move-only checker: rdar://151841926.
627+
// The move-only checker sometimes inserts destroy_addr within read-only static access scopes.
628+
// TODO: remove this once the bug is fixed.
629+
if beginAccess.isStatic {
630+
return nil
631+
}
632+
625633
switch beginAccess.accessKind {
626634
case .read:
627635
self = .readAccess(beginAccess)

test/SILOptimizer/licm_exclusivity.sil

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,12 @@ bb2:
153153
// CHECK-LABEL: sil @hoist_access_static : $@convention(thin) () -> () {
154154
// CHECK: [[GLOBAL:%.*]] = global_addr @globalX : $*X
155155
// CHECK: [[BEGIN:%.*]] = begin_access [read] [static] [[GLOBAL]] : $*X
156-
// CHECK-NEXT: load
157-
// CHECK-NEXT: br bb1
156+
157+
// Currently disabled because of a workaround in AliasAnalysis: rdar://151841926
158+
// xCHECK-NEXT: load
159+
// xCHECK-NEXT: br bb1
158160
// CHECK: apply
159-
// CHECK-NEXT: cond_br
161+
// xCHECK-NEXT: cond_br
160162
// CHECK: bb2
161163
// CHECK: end_access [[BEGIN]]
162164
// CHECK-LABEL: } // end sil function 'hoist_access_static'

0 commit comments

Comments
 (0)