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

"Show LLVM IR" and "Show ASM" are missing some functions #1032

Closed
RalfJung opened this issue Jan 9, 2024 · 5 comments
Closed

"Show LLVM IR" and "Show ASM" are missing some functions #1032

RalfJung opened this issue Jan 9, 2024 · 5 comments

Comments

@RalfJung
Copy link
Member

RalfJung commented Jan 9, 2024

I tried this code:

pub fn foo(x: i32) -> i32 { x }

Then I [edit: switched to release mode,] clicked "show LLVM IR" and expected to see the IR for this function.
However, the generated LLVM IR doesn't contain any function.

@RalfJung
Copy link
Member Author

RalfJung commented Jan 9, 2024

Interestingly, adding #[inline(never)] helps. But this is new, we used to be able to see the LLVM IR of functions without extra shenanigans like that.

I wonder if this is related to rust-lang/rust#116505, Cc @saethlin

@RalfJung
Copy link
Member Author

RalfJung commented Jan 9, 2024

Ah I guess this explains it. However that also says

And then wait for us to fix the inliner visibility issue, it is a bug and we should get to it eventually.

Is that bug tracked anywhere?

@shepmaster
Copy link
Member

@shepmaster shepmaster changed the title "Show LLVM IR" is missing some functions "Show LLVM IR" and "Show ASM" are missing some functions Jan 9, 2024
@saethlin
Copy link
Member

saethlin commented Jan 10, 2024

Is that bug tracked anywhere?

No. Probably I should track the whole tangled mess of the reachability analysis, MIR inlining with its query cycle avoidance, MIR collection, instantiation modes, and the various exceptions to that whole system that are carved out for special functions. I'm barely smart enough to hack on this system, but I'm getting better. Right now all I can really do is point out that it's troubling, not do anything to improve it.

But none of this is actually going to fix the situation for the playground and compiler explorer. People got used to the previous behavior of the compiler, where a hand-written fn item without any attributes would be eagerly codegenned in the current crate. This is at odds with making an efficient compiler, because in some situations we have learned that it is less work to lower in callers (if they exist!) rather than lower eagerly. (note the widespread perf improvements when cross-crate-inlining landed)

It is entirely plausible that we add a compiler flag to produce the behavior that tools like the playground want. But I don't know how to get that stabilized (compiler explorer at least seems not that interested in using an unstable option to produce the old behavior), and in the current situation in the compiler I am not even sure how to implement it without perturbing optimization of functions that call a cross-crate-inlinable function. If you press "Show LLVM IR" or "Show ASM" in the playground and get different output than you do locally because locally you're not using a playground-only flag, that seems like it significantly degrades the value of this feature.

@RalfJung
Copy link
Member Author

RalfJung commented Jan 11, 2024

That still seems worth an issue. Closing in favor of rust-lang/rust#119850.

@shepmaster feel free to reopen if you want to keep this visible in the playground issue tracker as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants