[SROA] Large array causes SROA pass OOM
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
- **Problem:** `AggLoadStoreRewriter` runs before SROA partitioning and recursively splits first-class aggregate loads and stores into scalar accesses. For a very large array, this can create a pathological amount of intermediate IR before later optimization passes can simplify it.
- **Example:** Given a 256 MB aggregate copy:
```llvm
%value = load [268435455 x i8], ptr %src, align 1
store [268435455 x i8] %value, ptr %dst, align 1
```
Running SROA first can attempt to create `extractvalue`, `getelementptr`, and `store` operations for every array element, and it will be OOM.
I try to reorder the pipelines(#210875), which run `MemCpyOpt` before SROA, but i think it's not the best fix, so open an issue.
Contributor guide
Research direction
Start by tracing AggLoadStoreRewriter in the SROA pass and reproduce the 256 MB aggregate load/store example. Compare the intermediate IR and memory behavior when MemCpyOpt runs before SROA; done means avoiding pathological per-element IR creation without introducing incorrect transformations.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100