Skip to content

Commit be9d290

Browse files
author
Joe Shajrawi
committed
[Exclusivity] Fix a bug wherein we miss detected a non conflicting in-scope access as conflicting
1 parent 244f8bb commit be9d290

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lib/SILOptimizer/Transforms/AccessEnforcementOpts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void AccessConflictAndMergeAnalysis::visitBeginAccess(
637637

638638
auto &outerAccessInfo = result.getAccessInfo(outerBeginAccess);
639639
// If there is no potential conflict, leave the outer access mapped.
640-
if (!outerAccessInfo.isDistinctFrom(beginAccessInfo))
640+
if (outerAccessInfo.isDistinctFrom(beginAccessInfo))
641641
continue;
642642

643643
LLVM_DEBUG(beginAccessInfo.dump();

test/SILOptimizer/access_enforcement_opts.sil

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ class RefElemClass {
13321332
// CHECK-NEXT: [[REFY:%.*]] = ref_element_addr %0 : $RefElemClass, #RefElemClass.y
13331333
// CHECK-NEXT: [[BEGINX:%.*]] = begin_access [modify] [dynamic] [[REFX]] : $*BitfieldOne
13341334
// CHECK: end_access [[BEGINX]] : $*BitfieldOne
1335-
// CHECK: [[BEGINY:%.*]] = begin_access [modify] [dynamic] [no_nested_conflict] [[REFY]] : $*Int32
1335+
// CHECK: [[BEGINY:%.*]] = begin_access [modify] [dynamic] [[REFY]] : $*Int32
13361336
// CHECK: [[BEGINX2:%.*]] = begin_access [modify] [dynamic] [no_nested_conflict] [[REFX]] : $*BitfieldOne
13371337
// CHECK-NEXT: end_access [[BEGINX2]] : $*BitfieldOne
13381338
// CHECK-NEXT: end_access [[BEGINY]] : $*Int32
@@ -1358,6 +1358,34 @@ bb0(%0 : $RefElemClass):
13581358
return %10 : $()
13591359
}
13601360

1361+
class RefElemNoConflictClass {
1362+
var x : Int32
1363+
var y : Int32
1364+
init()
1365+
}
1366+
1367+
// Checks that we can detect not having a nested conflict in class when we are accessing
1368+
// fields that do no alias
1369+
// CHECK-LABEL: sil @ref_elem_no_alias : $@convention(thin) (RefElemNoConflictClass) -> () {
1370+
// CHECK: [[REFX:%.*]] = ref_element_addr %0 : $RefElemNoConflictClass, #RefElemNoConflictClass.x
1371+
// CHECK-NEXT: [[REFY:%.*]] = ref_element_addr %0 : $RefElemNoConflictClass, #RefElemNoConflictClass.y
1372+
// CHECK: [[BEGINY:%.*]] = begin_access [modify] [dynamic] [no_nested_conflict] [[REFY]] : $*Int32
1373+
// CHECK: [[BEGINX:%.*]] = begin_access [modify] [dynamic] [no_nested_conflict] [[REFX]] : $*Int32
1374+
// CHECK-NEXT: end_access [[BEGINX]] : $*Int32
1375+
// CHECK-NEXT: end_access [[BEGINY]] : $*Int32
1376+
// CHECK-LABEL: } // end sil function 'ref_elem_no_alias'
1377+
sil @ref_elem_no_alias : $@convention(thin) (RefElemNoConflictClass) -> () {
1378+
bb0(%0 : $RefElemNoConflictClass):
1379+
%x = ref_element_addr %0 : $RefElemNoConflictClass, #RefElemNoConflictClass.x
1380+
%y = ref_element_addr %0 : $RefElemNoConflictClass, #RefElemNoConflictClass.y
1381+
%b2 = begin_access [modify] [dynamic] %y : $*Int32
1382+
%b3 = begin_access [modify] [dynamic] %x : $*Int32
1383+
end_access %b3 : $*Int32
1384+
end_access %b2 : $*Int32
1385+
%10 = tuple ()
1386+
return %10 : $()
1387+
}
1388+
13611389
// public func testStronglyConnectedComponent() {
13621390
// During the merge optimization,
13631391
// Check that we don't merge cross strongly component boundaries for now

0 commit comments

Comments
 (0)