Drop elaboration emits `O(N^2)` cleanup for partially-initialized aggregate literals
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
An aggregate literal of N droppable elements whose initializers can diverge could emit O(N^2) drop terminators. Which chokes LLVM's CVP pass and cost substantial time in optimized build.
For example, the following code will take over 60s to build with -O:
pub fn build(s: u64) -> Result<Big, ()> {
Ok(Big { f0: make_one(s ^ 0)?, /* … N fields … */ f127: make_one(s ^ 127)? })
}
See https://github.com/ashi009/cvp-llvm-repro for a runnable example.
Reproducible on 1.96.0 stable (LLVM 22.1.2) and 1.98.0-nightly e7815e522 (LLVM 22.1.6).
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.
Research direction
Start with the runnable example at ashi009/cvp-llvm-repro and reproduce the optimized build using the aggregate literal with diverging initializers. Trace Rust's drop elaboration and generated drop terminators into LLVM's CVP pass; done means the cleanup is no longer quadratic and the reproduced build avoids the reported optimization cost.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100