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

JumpThreading: fix bitwise not on non-booleans #131203

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

clubby789
Copy link
Contributor

Fixes #131195

Alternative to #131201

@rustbot
Copy link
Collaborator

rustbot commented Oct 3, 2024

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Oct 3, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 3, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@compiler-errors compiler-errors added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 3, 2024
@compiler-errors
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 3, 2024

📌 Commit fd35e82 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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 3, 2024
…piler-errors

JumpThreading: fix bitwise not on non-booleans

Fixes rust-lang#131195

Alternative to rust-lang#131201
@compiler-errors compiler-errors added the stable-nominated Nominated for backporting to the compiler in the stable channel. label Oct 3, 2024
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

Ok, well, this definitely causes a crash when building [email protected]

@bors r-

Let's actually land #131201, which is a more conservative fix. Then we can work on improving the jumpthreading optimization :)

Since cjgillot authored the jump threading optimization (I think?) I can pass this off to them.

r? @cjgillot

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 3, 2024
@clubby789
Copy link
Contributor Author

Looks like some miscompile in std 🤔 In my local testing I get println hanging on futex forever

@compiler-errors
Copy link
Member

I am very curious to learn what is wrong with this PR :D

@bors
Copy link
Contributor

bors commented Oct 4, 2024

☔ The latest upstream changes (presumably #131201) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung
Copy link
Member

RalfJung commented Oct 5, 2024

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 5, 2024
@clubby789
Copy link
Contributor Author

@rustbot ready
r? @RalfJung

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 6, 2024
@rustbot rustbot assigned RalfJung and unassigned cjgillot Oct 6, 2024
@clubby789
Copy link
Contributor Author

Threaded -> Option<()> through places where interp errors can happen. There's a few suspicious let Some(x) = .. else { return Some(()); } but I wanted to keep the behaviour for these as close to as the current

@RalfJung
Copy link
Member

RalfJung commented Oct 7, 2024

The unary_op(UnOp::Not part LGTM. But I'm not familiar with the jump threading parts so I'll bounce the review back for those structural changes.

r? @cjgillot

@rustbot rustbot assigned cjgillot and unassigned RalfJung Oct 7, 2024
@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor

@clubby789 I'm not convinced by the second commit. If we get an interpreter error, we should only abort the current backwards walk, not the whole pass.

@clubby789 clubby789 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 Oct 27, 2024
@clubby789 clubby789 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 27, 2024
@cjgillot
Copy link
Contributor

Threaded -> Option<()> through places where interp errors can happen. There's a few suspicious let Some(x) = .. else { return Some(()); } but I wanted to keep the behaviour for these as close to as the current

Do they actually cause a bug? Do you have a reproducer?

@clubby789
Copy link
Contributor Author

iirc all instances that I looked at seemed to be fine, and changing them to return None instead caused issues

@cjgillot
Copy link
Contributor

For the correctness in case of interpreter failure.
The correctness of the backtracking is ensured by mutated_statement clearing all relevant conditions. So if process_statement fails to insert a new condition, the obsolete ones are still removed from the state.
I'd rather have mutated_statement fixed if there is a bug, instead of an early exit contaminating everything.

@clubby789
Copy link
Contributor Author

Sorry, I'm not quite sure what you mean here. Do you want additional changes?
I believe that all the instances where a None isn't propogated are intended functionality, not bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-Zmir-opt-level miscompiles code with panic
10 participants