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

Fix BinOp ty() assertion and fn_sig() for closures #118846

Merged
merged 3 commits into from
Dec 12, 2023

Conversation

celinval
Copy link
Contributor

@celinval celinval commented Dec 12, 2023

BinOp::ty() was asserting that the argument types were primitives. However, the primitive check doesn't include pointers, which can be used in a BinaryOperation. Thus extend the arguments to include them.

Since I had to add methods to check for pointers in TyKind, I just went ahead and added a bunch more utility checks that can be handy for our users and fixed the fn_sig() method to also include closures.

@compiler-errors just wanted to confirm that today no BinaryOperation accept SIMD types. Is that correct?

r? @compiler-errors

Also added a few more util methods to TyKind to check for specific types.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 12, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 12, 2023

This PR changes Stable MIR

cc @oli-obk, @celinval, @spastorino, @ouz-a

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions.

just wanted to confirm that today no BinaryOperation accept SIMD types. Is that correct?

I don't think we lower SIMD intrinsics to MIR binops like we do for primitives, I can see it's not happening in compiler/rustc_mir_transform/src/lower_intrinsics.rs.

compiler/stable_mir/src/ty.rs Outdated Show resolved Hide resolved
compiler/stable_mir/src/ty.rs Outdated Show resolved Hide resolved
compiler/stable_mir/src/mir/body.rs Outdated Show resolved Hide resolved
@rustbot rustbot 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 Dec 12, 2023
@celinval
Copy link
Contributor Author

@compiler-errors let me know if there's anything else you would like me to change.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

@celinval
Copy link
Contributor Author

@bors r=@compiler-errors rollup

@bors
Copy link
Contributor

bors commented Dec 12, 2023

📌 Commit 638b08e has been approved by compiler-errors

It is now in the queue for this repository.

@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 12, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 12, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#118445 (Let `reuse` look inside git submodules)
 - rust-lang#118756 (use bold magenta instead of bold white for highlighting)
 - rust-lang#118797 (End locals' live range before suspending coroutine)
 - rust-lang#118840 (remove some redundant clones)
 - rust-lang#118844 (Monomorphize args while building Instance body in StableMIR)
 - rust-lang#118846 (Fix BinOp `ty()` assertion and `fn_sig()` for closures)
 - rust-lang#118848 (Add myself back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d67e80f into rust-lang:master Dec 12, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 12, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 12, 2023
Rollup merge of rust-lang#118846 - celinval:smir-ty-methods, r=compiler-errors

Fix BinOp `ty()` assertion and `fn_sig()` for closures

`BinOp::ty()` was asserting that the argument types were primitives. However, the primitive check doesn't include pointers, which can be used in a `BinaryOperation`. Thus extend the arguments to include them.

Since I had to add methods to check for pointers in TyKind, I just went ahead and added a bunch more utility checks that can be handy for our users and fixed the `fn_sig()` method to also include closures.

`@compiler-errors` just wanted to confirm that today no `BinaryOperation` accept SIMD types. Is that correct?

r? `@compiler-errors`
celinval added a commit to model-checking/kani that referenced this pull request Dec 13, 2023
This migration was fairly straight forward, most constructs have a 1:1
map from internal APIs to StableMIR APIs. I've also removed the
`is_coroutine()` and the `is_box()` methods from `ty_stable`, since they
were added to the StableMIR APIs together with other type methods here:
rust-lang/rust#118846.
@workingjubilee
Copy link
Member

I don't think we lower SIMD intrinsics to MIR binops like we do for primitives, I can see it's not happening in compiler/rustc_mir_transform/src/lower_intrinsics.rs.

Correct, SIMD operations have their own path because they tend to be expressed as "don't think too hard about what's happening here in the MIR, this is just going to be lowered by the CG backend".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants