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

rustc: split FnAbi's into definitions/direct calls ("of_instance") and indirect calls ("of_fn_ptr"). #65947

Merged
merged 20 commits into from
Dec 4, 2019

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Oct 29, 2019

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
  • 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

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 29, 2019
@eddyb
Copy link
Member Author

eddyb commented Oct 30, 2019

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Oct 30, 2019

⌛ Trying commit a3153cb25e0c2eca2a987433763f40383a774cf8 with merge 924ec06b909e3054669b8cec62e173ff2e962a06...

@bors
Copy link
Contributor

bors commented Oct 30, 2019

☀️ Try build successful - checks-azure
Build commit: 924ec06b909e3054669b8cec62e173ff2e962a06 (924ec06b909e3054669b8cec62e173ff2e962a06)

@rust-timer
Copy link
Collaborator

Queued 924ec06b909e3054669b8cec62e173ff2e962a06 with parent 0b7e28a, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 924ec06b909e3054669b8cec62e173ff2e962a06, comparison URL.

@varkor
Copy link
Member

varkor commented Nov 8, 2019

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

@rust-highfive rust-highfive assigned nagisa and unassigned varkor Nov 8, 2019
@varkor
Copy link
Member

varkor commented Nov 8, 2019

this could easily be done for intrinsics as well, to allow their reification, but I didn't do it

Does this mean #15694 could be addressed?

@eddyb
Copy link
Member Author

eddyb commented Nov 8, 2019

Does this mean #15694 could be addressed?

@varkor Yeah, and it's been possible ever since MIR shims were added, really.
I'm just making the diff for that be a couple less lines from a dozen, or thereabouts.

@bors

This comment has been minimized.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2019
@JohnCSimon

This comment has been minimized.

Copy link
Member

@nagisa nagisa left a 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.

src/librustc/ty/instance.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/callee.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/intrinsic.rs Show resolved Hide resolved
@JohnCSimon

This comment has been minimized.

@eddyb
Copy link
Member Author

eddyb commented Nov 27, 2019

@nagisa @oli-obk I've added 6 more commits, which should deal with both the review comments and my own concerns (mostly wrt the misusability of Instance::fn_sig).

@eddyb
Copy link
Member Author

eddyb commented Dec 3, 2019

@bors r=oli-obk,nagisa

@bors
Copy link
Contributor

bors commented Dec 3, 2019

📌 Commit c2f4c57 has been approved by oli-obk,nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 3, 2019
@eddyb eddyb mentioned this pull request Dec 3, 2019
@bors
Copy link
Contributor

bors commented Dec 4, 2019

⌛ Testing commit c2f4c57 with merge 5f1d6c4...

bors added a commit that referenced this pull request Dec 4, 2019
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
@bors
Copy link
Contributor

bors commented Dec 4, 2019

☀️ Test successful - checks-azure
Approved by: oli-obk,nagisa
Pushing 5f1d6c4 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 4, 2019
@bors bors merged commit c2f4c57 into rust-lang:master Dec 4, 2019
@eddyb eddyb deleted the fn-abi branch December 4, 2019 11:29
Centril added a commit to Centril/rust that referenced this pull request Dec 7, 2019
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
Centril added a commit to Centril/rust that referenced this pull request Dec 7, 2019
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
Centril added a commit to Centril/rust that referenced this pull request Dec 8, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants