Skip to content

Constprop can create aggregates that won't get deaggregated anymore #75481

Closed
@bjorn3

Description

@bjorn3

Before #73656 the deaggregator ran after aggregates. Now it doesn't anymore, breaking cg_clif.

static mut NUM: i32 = 0;

fn store_42() {
    unsafe {
        NUM = 6 * 7;
    }
}
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn store_42() -> () {
    let mut _0: ();                      // return place in scope 0 at src/lib.rs:3:15: 3:15
    let mut _1: (i32, bool);             // in scope 0 at src/lib.rs:5:15: 5:20
    let mut _2: *mut i32;                // in scope 0 at src/lib.rs:5:9: 5:12
    scope 1 {
    }

    bb0: {
        _1 = (const 42_i32, const false); // scope 1 at src/lib.rs:5:15: 5:20
                                         // ty::Const
                                         // + ty: i32
                                         // + val: Value(Scalar(0x0000002a))
                                         // mir::Constant
                                         // + span: src/lib.rs:5:15: 5:20
                                         // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
                                         // ty::Const
                                         // + ty: bool
                                         // + val: Value(Scalar(0x00))
                                         // mir::Constant
                                         // + span: src/lib.rs:5:15: 5:20
                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
        StorageLive(_2);                 // scope 1 at src/lib.rs:5:9: 5:12
        _2 = const {alloc0: *mut i32};   // scope 1 at src/lib.rs:5:9: 5:12
                                         // ty::Const
                                         // + ty: *mut i32
                                         // + val: Value(Scalar(alloc0))
                                         // mir::Constant
                                         // + span: src/lib.rs:5:9: 5:12
                                         // + literal: Const { ty: *mut i32, val: Value(Scalar(alloc0)) }
        (*_2) = move (_1.0: i32);        // scope 1 at src/lib.rs:5:9: 5:20
        StorageDead(_2);                 // scope 1 at src/lib.rs:5:20: 5:21
        _0 = const ();                   // scope 1 at src/lib.rs:4:5: 6:6
                                         // ty::Const
                                         // + ty: ()
                                         // + val: Value(Scalar(<ZST>))
                                         // mir::Constant
                                         // + span: src/lib.rs:4:5: 6:6
                                         // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
        return;                          // scope 0 at src/lib.rs:7:2: 7:2
    }
}

alloc0 (static: NUM, size: 4, align: 4) {
    00 00 00 00                                     │ ....
}

static mut NUM: i32 = {
    let mut _0: i32;                     // return place in scope 0 at src/lib.rs:1:17: 1:20

    bb0: {
        _0 = const 0_i32;                // scope 0 at src/lib.rs:1:23: 1:24
                                         // ty::Const
                                         // + ty: i32
                                         // + val: Value(Scalar(0x00000000))
                                         // mir::Constant
                                         // + span: src/lib.rs:1:23: 1:24
                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
        return;                          // scope 0 at src/lib.rs:1:1: 1:25
    }
}

@rustbot modify labels: +A-mir +A-mir-opt +A-cranelift +C-bug +T-compiler

cc @oli-obk (PR author)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-craneliftThings relevant to the [future] cranelift backendA-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions