-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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: Add inline(maybe), which only writes the AST to crate metadata. #6616
Conversation
If |
As far as I understand there are 4 inline settings for functions in LLVM: always, hint (our |
On first glance I'm a little uncomfortable with adding yet another type of inlining. Maybe we can solicit further feedback before committing. |
There is definitely scope for it being useful, with LLVM's inlinehint being quite aggressive, the standard inlining heuristics might be preferable, but then you don't get cross-crate inlining. The idea behind this is sound though. |
@huonw: needs a rebase |
@thestinger done! |
Hey I just met you, and this is crazy, but here's my AST, inline me maybe? |
I prefer to not add
An inline maybe function is guaranteed to be copied into every crate where it's used, even if not inlined. This is probably the right behavior since it's consistent - you know that no When an I suppose that it is difficult to know when to choose We don't have code that needs |
Closing. Feel free to reopen or revisit this later if you disagree. |
…ffen New lint: exhaustive_enums, exhaustive_structs Fixes rust-lang#6616 changelog: Added restriction lint: `exhaustive_enums`, `exhaustive_structs`
This gives LLVM the data required to inline (i.e. writes the AST to the crate), but doesn't force it to, like
#[inline]
(which is actually just a hint, but is apparently very aggressive) or#[inline(always)]
.I'm not sure how to test, but given:
With a pre-
inline(maybe)
rustc the asm forinline_maybe2.rs
contains:With this patch, the
foo
call is inlined and constant-folded away. (with-O
.)With a huge
foo
(that wouldn't be normally inlined, even within the same crate) withinline(maybe)
, the actual call remains ininline_maybe2
, i.e. it isn't inlined.I'm not sure about two lines (my line comment), but I'm unsure who's most appropriate to consult/familiar with this code.