-
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
rustc: split FnAbi's into definitions/direct calls ("of_instance") and indirect calls ("of_fn_ptr"). #65947
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit a3153cb25e0c2eca2a987433763f40383a774cf8 with merge 924ec06b909e3054669b8cec62e173ff2e962a06... |
☀️ Try build successful - checks-azure |
Queued 924ec06b909e3054669b8cec62e173ff2e962a06 with parent 0b7e28a, future comparison URL. |
Finished benchmarking try commit 924ec06b909e3054669b8cec62e173ff2e962a06, comparison URL. |
I've looked through, and while the changes look sensible to me, I'm not familiar enough to be sure I haven't missed some detail, so I'm going to reassign. r? @nagisa |
Does this mean #15694 could be addressed? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM.
r=me once you’re comfortable with landing this.
This comment has been minimized.
This comment has been minimized.
@bors r=oli-obk,nagisa |
📌 Commit c2f4c57 has been approved by |
rustc: split FnAbi's into definitions/direct calls ("of_instance") and indirect calls ("of_fn_ptr"). After this PR: * `InstanceDef::Virtual` is only used for "direct" virtual calls, and shims around those calls use `InstanceDef::ReifyShim` (i.e. for `<dyn Trait as Trait>::f as fn(_)`) * this could easily be done for intrinsics as well, to allow their reification, but I didn't do it * `FnAbi::of_instance` is **always** used for declaring/defining an `fn`, and for direct calls to an `fn` * this is great for e.g. #65881 (`#[track_caller]`), which can introduce the "caller location" argument into "codegen signatures" by only changing `FnAbi::of_instance`, after this PR * `FnAbi::of_fn_ptr` is used primarily for indirect calls, i.e. to `fn` pointers * *not* virtual calls (which use `FnAbi::of_instance` with `InstanceDef::Virtual`) * there's also a couple uses where the `rustc_codegen_llvm` needs to declare (i.e. FFI-import) an LLVM function that has no Rust declaration available at all * at least one of them could probably be a "weak lang item" instead As there are many steps, this PR is best reviewed commit by commit - some of which arguably should be in their own PRs, I may have gotten carried away a bit. cc @nagisa @rkruppe @oli-obk @anp
☀️ Test successful - checks-azure |
Cleanup BodyCache After this PR: - `BodyCache` is renamed to `BodyAndCache` - `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache` - `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in rust-lang#65947) cc @eddyb @oli-obk
Cleanup BodyCache After this PR: - `BodyCache` is renamed to `BodyAndCache` - `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache` - `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in rust-lang#65947) cc @eddyb @oli-obk
Cleanup BodyCache After this PR: - `BodyCache` is renamed to `BodyAndCache` - `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache` - `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in rust-lang#65947) cc @eddyb @oli-obk
After this PR:
InstanceDef::Virtual
is only used for "direct" virtual calls, and shims around those calls useInstanceDef::ReifyShim
(i.e. for<dyn Trait as Trait>::f as fn(_)
)FnAbi::of_instance
is always used for declaring/defining anfn
, and for direct calls to anfn
#[track_caller]
), which can introduce the "caller location" argument into "codegen signatures" by only changingFnAbi::of_instance
, after this PRFnAbi::of_fn_ptr
is used primarily for indirect calls, i.e. tofn
pointersFnAbi::of_instance
withInstanceDef::Virtual
)rustc_codegen_llvm
needs to declare (i.e. FFI-import) an LLVM function that has no Rust declaration available at allAs there are many steps, this PR is best reviewed commit by commit - some of which arguably should be in their own PRs, I may have gotten carried away a bit.
cc @nagisa @rkruppe @oli-obk @anp