-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Enable -Zshare-generics for inline(never) functions #123244
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,21 @@ pub fn foo<T>(x: T) -> (T, u32, i8) { | |
#[inline(never)] | ||
fn bar<T>(x: T) -> (T, Struct) { | ||
let _ = not_exported_and_not_generic(0); | ||
exported_and_generic::<u32>(0); | ||
(x, Struct(1)) | ||
} | ||
|
||
pub static F: fn(u32) -> u32 = exported_and_generic::<u32>; | ||
|
||
// These should not contribute to the codegen items of other crates. | ||
|
||
// This is generic, but it's only instantiated with a u32 argument and that instantiation is present | ||
// in the local crate (see F above). | ||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this testing what we want? I was expecting to see a cross-crate call to a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is indeed checking that behavior, though it's rather obscure. As per the comment just above ("These should not contribute...") we are implicitly checking that these functions are absent in the mono-items of the downstream crate (tests/codegen-units/partitioning/extern-generic.rs) since they're not listed as I suppose we could try to write a more direct test case? But this also tests that the property holds transitively (i.e., we don't codegen the called function twice with inline(never) even if it's not directly being called). IIRC, before my changes, this would fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see! This is very interconnected, and I should really be used to that by now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I checked and yes the test does fail without the rest of this PR. |
||
#[inline(never)] | ||
pub fn exported_and_generic<T>(x: T) -> T { | ||
x | ||
} | ||
|
||
#[inline(never)] | ||
pub fn exported_but_not_generic(x: i32) -> i64 { | ||
x as i64 | ||
|
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.