rust-lang / rust-lang/rust

Code size regression iterating an array (opt-level=z) after 1.82.0

Open
#132,890 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM C-bug I-heavy P-low regression-untriaged T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code:

#![no_main]
#[no_mangle]
pub fn f(a: i32) -> i32 { a + a }

#[no_mangle]
pub fn g(a: [i32; 5]) -> i32 {
    let mut sum = 0;
    let arr = [1, 2, 3, 4, 5];
    for i in a.iter().chain(arr.iter()) {
        sum += i;
    }
    sum
}

Link: https://godbolt.org/z/14KM5KnPx

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Rust example from the issue in the linked Godbolt Compiler Explorer and compare code size with 1.82.0. Investigate the compiler optimization path used for iterating over the chained arrays; done means identifying and correcting the post-1.82.0 regression with coverage for the reported case.

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
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.