Skip to content

Absurd codegen with owned trait objects and enums #11549

Closed
@alexcrichton

Description

@alexcrichton

Consider a small rust program such as this

pub trait A { fn foo(&self) {} }

#[inline(never)]
pub fn foo(slot: &mut Option<~A>) {
    slot.get_mut_ref().foo();
}

This program should essentially be a check of the discriminant followed by a vtable load + dynamic dispatch. Consider, however, the --opt-level=3 IR:

https://gist.github.com/alexcrichton/8429375

Note that I had to put that in a gist because it was too large to inline here. In summary this is generating 1500 lines of IR. This turns into kilobytes of code.

Something very odd is going on here, and this really needs to be fixed.

Nominating

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions