Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ private extension AnalyzedInstructions {
continue
}

guard let splitLoads = loadInst.trySplit(alongPath: accessPath.projectionPath, context) else {
guard let projectionPath = loadInst.operand.value.accessPath.getProjection(to: accessPath),
let splitLoads = loadInst.trySplit(alongPath: projectionPath, context) else {
newLoads.push(loadInst)
return false
}
Expand Down
41 changes: 41 additions & 0 deletions test/SILOptimizer/licm.sil
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,47 @@ bb2:
return %r1 : $()
}

struct Outer {
var interactions: Inner
}

public struct Inner {
public let x: Int
var storage: ContiguousArray<Double>
}

sil @$get_array_from_inner : $@convention(method) (Inner) -> (ContiguousArray<Double>)

// Make sure we project load access path to matching store access path.
// Otherwise the pass could crash.
//
// CHECK-LABEL: sil @project_load_path_before_splitting_crash :
// CHECK: load
// CHECK: bb1(%8 : $ContiguousArray<Double>):
// CHECK: bb3:
// CHECK: store
// CHECK: } // end sil function 'project_load_path_before_splitting_crash'
sil @project_load_path_before_splitting_crash : $@convention(thin) (@inout Outer) -> () {
bb0(%0 : $*Outer):
%1 = struct_element_addr %0, #Outer.interactions
%2 = struct_element_addr %1, #Inner.storage
br bb1

bb1:
%4 = load %1
%5 = function_ref @$get_array_from_inner : $@convention(method) (Inner) -> ContiguousArray<Double>
%6 = apply %5(%4) : $@convention(method) (Inner) -> ContiguousArray<Double>
store %6 to %2
cond_br undef, bb2, bb3

bb2:
br bb1

bb3:
%10 = tuple ()
return %10
}

// CHECK-LABEL: sil @dont_hoist_builtin_once_memory_conflict :
// CHECK: function_ref
// CHECK: br bb1
Expand Down