File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
SwiftCompilerSources/Sources/Optimizer/FunctionPasses Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -587,7 +587,8 @@ private extension AnalyzedInstructions {
587587 continue
588588 }
589589
590- guard let splitLoads = loadInst. trySplit ( alongPath: accessPath. projectionPath, context) else {
590+ guard let projectionPath = loadInst. operand. value. accessPath. getProjection ( to: accessPath) ,
591+ let splitLoads = loadInst. trySplit ( alongPath: projectionPath, context) else {
591592 newLoads. push ( loadInst)
592593 return false
593594 }
Original file line number Diff line number Diff line change @@ -1549,6 +1549,47 @@ bb2:
15491549 return %r1 : $()
15501550}
15511551
1552+ struct Outer {
1553+ var interactions: Inner
1554+ }
1555+
1556+ public struct Inner {
1557+ public let x: Int
1558+ var storage: ContiguousArray<Double>
1559+ }
1560+
1561+ sil @$get_array_from_inner : $@convention(method) (Inner) -> (ContiguousArray<Double>)
1562+
1563+ // Make sure we project load access path to matching store access path.
1564+ // Otherwise the pass could crash.
1565+ //
1566+ // CHECK-LABEL: sil @project_load_path_before_splitting_crash :
1567+ // CHECK: load
1568+ // CHECK: bb1(%8 : $ContiguousArray<Double>):
1569+ // CHECK: bb3:
1570+ // CHECK: store
1571+ // CHECK: } // end sil function 'project_load_path_before_splitting_crash'
1572+ sil @project_load_path_before_splitting_crash : $@convention(thin) (@inout Outer) -> () {
1573+ bb0(%0 : $*Outer):
1574+ %1 = struct_element_addr %0, #Outer.interactions
1575+ %2 = struct_element_addr %1, #Inner.storage
1576+ br bb1
1577+
1578+ bb1:
1579+ %4 = load %1
1580+ %5 = function_ref @$get_array_from_inner : $@convention(method) (Inner) -> ContiguousArray<Double>
1581+ %6 = apply %5(%4) : $@convention(method) (Inner) -> ContiguousArray<Double>
1582+ store %6 to %2
1583+ cond_br undef, bb2, bb3
1584+
1585+ bb2:
1586+ br bb1
1587+
1588+ bb3:
1589+ %10 = tuple ()
1590+ return %10
1591+ }
1592+
15521593// CHECK-LABEL: sil @dont_hoist_builtin_once_memory_conflict :
15531594// CHECK: function_ref
15541595// CHECK: br bb1
You can’t perform that action at this time.
0 commit comments