-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
MIR: use HirId instead of NodeId to avoid cycles while inlining #71285
MIR: use HirId instead of NodeId to avoid cycles while inlining #71285
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
b716e9e
to
81d7283
Compare
81d7283
to
a270ba6
Compare
This seems reasonable, but I'm not familiar enough with the subtleties to be sure, so reassigning to the reviewer of the linked PR. |
#71197 only needed to sort things so that error messages would be produced in source order. In this case, we need to define an arbitrary order for all callable functions to avoid inlining cycles. Why not use the Also, I don't believe perf runs have MIR inlining enabled. If that's true, any slowdown caused by looking up all these spans wouldn't have been visible. |
If the order can be arbitrary then it makes sense to just use |
I don't know. The goal is to have the exact same optimizations applied across incremental runs. If you can prove that is indeed what happens, then have at it. However, I suspect that if it were that simple, |
A part of a rust/src/librustc_hir/definitions.rs Lines 35 to 45 in df768c5
This means that if functions are reordered, comparing the order of the |
a270ba6
to
144ca6b
Compare
144ca6b
to
3c455fe
Compare
@bors r+ @ljedrz Feel free to explore the interaction between incremental and the current approach to avoiding inlining cycles. Note that more robust approach to MIR inlining in cyclic call graphs would eliminate that issue, along with several others. This is not a simple problem, however. See #43542. |
📌 Commit 3c455fe has been approved by |
Rollup of 4 pull requests Successful merges: - rust-lang#69362 (Stabilize most common subset of alloc_layout_extras) - rust-lang#71174 (Check that main/start is not async) - rust-lang#71285 (MIR: use HirId instead of NodeId to avoid cycles while inlining) - rust-lang#71346 (Do not build tools if user do not want them) Failed merges: r? @ghost
I wanted to see if I could limit the number of uses of
NodeId
whenHirId
is available and I saw that some of the MIRInliner
code could useSpan
instead ofNodeId
, not unlike in #71197.If I'm understanding the reason for not callingoptimized_mir
in incremental builds here correctly, this change could also allow us to do so.This change could affect performance, so if this approach makes sense, a perf run is probably a good idea.