Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference MIR output emitted from rustc 1.67 and rustc 1.70 #112878

Closed
yanliu18 opened this issue Jun 21, 2023 · 2 comments
Closed

Difference MIR output emitted from rustc 1.67 and rustc 1.70 #112878

yanliu18 opened this issue Jun 21, 2023 · 2 comments
Labels
C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.

Comments

@yanliu18
Copy link

Code

I tried this code:

// add.rs
pub fn main() {
    let x = add();
    println!("1 + 2 = {x}")
}

fn add() -> i32 {
    let x = 1;
    let y = 2;
    x + y
}

Running rustc add.rs --emit mir produces different results.
I expected to see this happen (version info: rustc 1.68.0-nightly (afaf3e0 2023-01-14)) :

    bb0: {
        _1 = const 1_i32;                // scope 0 at assignments.rs:7:13: 7:14
        _2 = const 2_i32;                // scope 1 at assignments.rs:8:13: 8:14
        _0 = const 3_i32;                // scope 2 at assignments.rs:9:5: 9:10
        return;                          // scope 0 at assignments.rs:10:2: 10:2
    }

Instead, this happened (version info: rustc 1.72.0-nightly (fe7454b 2023-06-19))

    bb0: {
        _1 = const 1_i32;
        _2 = const 2_i32;
        _3 = CheckedAdd(_1, _2);
        assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", _1, _2) -> bb1;
    }

    bb1: {
        _0 = move (_3.0: i32);
        return;
    }

It seems ConstProp is removed from the newer rustc versions, by looking into dumped mir in the nightly build (version 1.68 and 1.72).

Is this change permanent? or if anyone could explain the reasons of removing? Thank you.

@yanliu18 yanliu18 added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jun 21, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 21, 2023
@matthiaskrgr
Copy link
Member

#109900

@yanliu18
Copy link
Author

Thanks.

@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.
Projects
None yet
Development

No branches or pull requests

4 participants