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

rustc: Don't inline in CGUs at -O0 #45075

Merged
merged 1 commit into from
Oct 9, 2017
Merged

Commits on Oct 8, 2017

  1. rustc: Don't inline in CGUs at -O0

    This commit tweaks the behavior of inlining functions into multiple codegen
    units when rustc is compiling in debug mode. Today rustc will unconditionally
    treat `#[inline]` functions by translating them into all codegen units that
    they're needed within, marking the linkage as `internal`. This commit changes
    the behavior so that in debug mode (compiling at `-O0`) rustc will instead only
    translate `#[inline]` functions into *one* codegen unit, forcing all other
    codegen units to reference this one copy.
    
    The goal here is to improve debug compile times by reducing the amount of
    translation that happens on behalf of multiple codegen units. It was discovered
    in rust-lang#44941 that increasing the number of codegen units had the adverse side
    effect of increasing the overal work done by the compiler, and the suspicion
    here was that the compiler was inlining, translating, and codegen'ing more
    functions with more codegen units (for example `String` would be basically
    inlined into all codegen units if used). The strategy in this commit should
    reduce the cost of `#[inline]` functions to being equivalent to one codegen
    unit, which is only translating and codegen'ing inline functions once.
    
    Collected [data] shows that this does indeed improve the situation from [before]
    as the overall cpu-clock time increases at a much slower rate and when pinned to
    one core rustc does not consume significantly more wall clock time than with one
    codegen unit.
    
    One caveat of this commit is that the symbol names for inlined functions that
    are only translated once needed some slight tweaking. These inline functions
    could be translated into multiple crates and we need to make sure the symbols
    don't collideA so the crate name/disambiguator is mixed in to the symbol name
    hash in these situations.
    
    [data]: rust-lang#44941 (comment)
    [before]: rust-lang#44941 (comment)
    alexcrichton committed Oct 8, 2017
    Configuration menu
    Copy the full SHA
    4b2bdf7 View commit details
    Browse the repository at this point in the history