[LSROA] Array support
Open
enhancement
llvm:transforms
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
We should update the LSROA pass to analyze loaded indices of arrays and only extract those.
The current LSROA implementation only splits load/stores on structs, not arrays. This means if a global array is copied in a temporary and a single element is loaded, the full array may be copied (for example if it's in a different address space, like it is in SPIR-V).
Acceptance Criteria
Given some IR with a structured.alloc of an array, where it loads and stores to individual elements via structured.gep:
define i32 @test_simple_array() {
entry:
%tmp = call elementtype([10 x i32]) ptr @llvm.structured.alloca.p0()
%ptr = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype([10 x i32]) %tmp, i32 0)
store i32 0, ptr %ptr
%res = load i32, ptr %ptr
ret i32 %res
}
We should be able to elminate the structured.gep and operate on the individual elements directly:
define i32 @test_simple_array() {
entry:
%tmp_i32 = call elementtype(i32) ptr @llvm.structured.alloca.p0()
store i32 0, ptr %tmp_i32
%res = load i32, ptr %tmp_i32
ret i32 %res
}
We will need to update the existing LSROA/array.ll test case to show that this works.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.