Skip to content

Cross-crate #[inline] functions are handled badly in unoptimized builds #30933

Closed
@jonas-schievink

Description

@jonas-schievink

Consider this simple code:

fn main() {
    let _ = Vec::<u8>::new();
}

When generating LLVM IR on the Playpen, my browser freezes for several seconds. With debug info, this generates 85 KiB of LLVM IR (1319 loc), without debug info its still 41K (857 loc).

The LLVM IR contains dozens of functions declared in std or core: Drop glue, Deref impls, even allocation functions and iterators (presumably used by the drop glue)! Despite being marked #[inline], all of these functions should be available inside of std and core and so we could just link to them instead of retranslating all of them.

Interestingly, because we're compiling everything in debug mode, no function calls will actually get inlined and the inlined functions will run slower then if we would just link to their optimized counterparts (since AFAIK std and core are always shipped with optimizations).

This worsens compile times and unoptimized code performance (although I haven't measured by how much).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions