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

generate MIR for constants and statics #33106

Closed
wants to merge 3 commits into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 20, 2016

This doesn't generate MIR for associated constants

r? @eddyb

cc @tsion

Example MIR generated for the C constant in the test:

// MIR for `C`
// node_id = 4
// pass_name = mir_map
// disambiguator = 0

fn C() -> i32 {

    bb0: {
        // Enter Scope(0)
        // Enter Scope(1)
        // Enter Scope(2)
        // Exit Scope(2)
        // Enter Scope(3)
        // Exit Scope(3)
        return = Add(const 5i32, const 6i32); // Scope(1) at mir_constant.rs:16:16: 16:21
        goto -> bb1; // Scope(0) at mir_constant.rs:16:1: 16:22
    }

    bb1: {
        return; // Scope(0) at mir_constant.rs:16:1: 16:22
    }
    Scope(0) {
        Extent: DestructionScope(4)
        Scope(1) {
            Parent: Scope(0)
            Extent: Misc(6)
            Scope(2) {
                Parent: Scope(1)
                Extent: Misc(7)
            Scope(3) {
                Parent: Scope(1)
                Extent: Misc(8)
}

and simplified:

// MIR for `C`
// node_id = 4
// pass_name = simplify_cfg
// disambiguator = 0

fn C() -> i32 {

    bb0: {
        return = Add(const 5i32, const 6i32); // Scope(1) at mir_constant.rs:16:16: 16:21
        goto -> bb1; // Scope(0) at mir_constant.rs:16:1: 16:22
    }

    bb1: {
        return; // Scope(0) at mir_constant.rs:16:1: 16:22
    }
    Scope(0) {
        Scope(1) {
            Parent: Scope(0)
            Scope(2) {
                Parent: Scope(1)
            Scope(3) {
                Parent: Scope(1)
}

assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
assert_eq!(builder.cfg.start_new_block(), END_BLOCK);

let call_site_extent = tcx.region_maps.item_extent(id);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the extent be for the item or the expression?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For constants and statics, item. For arbitrary expressions the extent of the binding to which the expression value is bound to.

oli-obk added 3 commits April 21, 2016 12:38
This does not generate MIR for associated constants
@eddyb
Copy link
Member

eddyb commented Apr 21, 2016

@oli-obk I'm so sorry about this, I had been working on #33130 since last week, I should've split it into two parts, the first half covers everything you did here (plus associated const support).

@oli-obk oli-obk closed this Apr 21, 2016
@oli-obk oli-obk deleted the mir_constants branch April 21, 2016 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants