Skip to content

Add atomic min and max #1721

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

Merged
merged 2 commits into from
Mar 2, 2021
Merged

Conversation

henryboisdequin
Copy link
Contributor

@henryboisdequin henryboisdequin commented Feb 23, 2021

Closes #1718
Previous attempt: #1653

TODO:

  • Merge atomic_op and atomic_min_max functions
  • Fix CI

Note: this PR also removes arbitrary trailing whitespace and generally formats the affected files

@henryboisdequin henryboisdequin marked this pull request as draft February 23, 2021 14:30
@RalfJung
Copy link
Member

Thanks a lot for the PR. :)

this PR also removes arbitrary trailing whitespace and generally formats the affected files

This causes quite a lot of noise, which makes review harder. Can you make the formatting changes a separate commit in the PR, or (even better) create a separate format-only PR? (Please don't rustfmt the entire repository, only these two files. There are some other files where rustfmt does a bad job, so I am waiting for some rustfmt fixes before formatting the entire repository.)

@henryboisdequin henryboisdequin changed the title Add atomic min and max WIP: Add atomic min and max Feb 24, 2021
@henryboisdequin
Copy link
Contributor Author

@RalfJung As you suggested in this comment, I've merged the atomic_op and atomic_min_max functions by using this enum:

enum AtomicOp {
    MirOp(mir::BinOp, bool),
    Max,
    Min,
}

Also, how do I fix the CI errors (I'm not sure how to should I implement the trait the diagnostic suggested -the code with errors was from the previous PR-)?

@RalfJung
Copy link
Member

(I'm afraid I will probably not be able to take a look at the CI errors at least until the weekend, I am quite busy until next Tuesday.)

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch 4 times, most recently from 2128265 to 304d22a Compare February 24, 2021 10:50
@henryboisdequin
Copy link
Contributor Author

@oli-obk Do you know what the problem is?

Error from CI:

normalized stderr:
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `8192`,
 right: `4096`', $DIR/atomic.rs:88:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


expected stderr:


diff of stderr:

+thread 'main' panicked at 'assertion failed: `(left == right)`
+  left: `8192`,
+ right: `4096`', $DIR/atomic.rs:88:5
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
+

The actual stderr differed from the expected stderr.
Actual stderr saved to /tmp/compiletestswsV4Q/atomic.stderr
To update references, run this command from build directory:
tests/run-pass/update-references.sh '/tmp/compiletestswsV4Q' 'atomic.rs'

error: 1 errors occurred comparing output.
status: exit code: 101
command: "/home/runner/work/miri/miri/target/x86_64-unknown-linux-gnu/release/miri" "tests/run-pass/atomic.rs" "-L" "/tmp/compiletestswsV4Q" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletestswsV4Q/atomic.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "--sysroot" "/home/runner/.cache/miri/HOST" "-L" "/tmp/compiletestswsV4Q/atomic.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `8192`,
 right: `4096`', tests/run-pass/atomic.rs:88:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

------------------------------------------

test [ui] run-pass/atomic.rs ... FAILED

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch 5 times, most recently from c865a35 to e574714 Compare March 1, 2021 11:44
@oli-obk oli-obk marked this pull request as ready for review March 1, 2021 12:01
@henryboisdequin henryboisdequin changed the title WIP: Add atomic min and max Add atomic min and max Mar 1, 2021
@henryboisdequin henryboisdequin requested a review from RalfJung March 1, 2021 12:04
@henryboisdequin
Copy link
Contributor Author

@oli-obk CI still fails though...

@oli-obk
Copy link
Contributor

oli-obk commented Mar 1, 2021

Yea, that's a regular build error, I approved the general code. Looks like you have references when a noon-reference was expected and an ImmTy instead of an Immedidate. If you deref an ImmTy you get an Immediate.

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from e574714 to 8d7a8b1 Compare March 1, 2021 12:11
@henryboisdequin
Copy link
Contributor Author

@oli-obk Understood! I didn't know that, thanks. I've changed the code accordingly.

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from 8d7a8b1 to d0c223e Compare March 1, 2021 12:15
@oli-obk
Copy link
Contributor

oli-obk commented Mar 1, 2021

Just out of curiosity: you are not building locally at all?

@henryboisdequin
Copy link
Contributor Author

henryboisdequin commented Mar 1, 2021

Just out of curiosity: you are not building locally at all?

@oli-obk No not really, I will next time though. Not sure why I'm not.

Edit:

Well, I kind of do have a reason: it takes more time to build locally than to look at the CI.

@RalfJung
Copy link
Member

RalfJung commented Mar 1, 2021

this PR also removes arbitrary trailing whitespace and generally formats the affected files

This causes quite a lot of noise, which makes review harder. Can you make the formatting changes a separate commit in the PR, or (even better) create a separate format-only PR? (Please don't rustfmt the entire repository, only these two files. There are some other files where rustfmt does a bad job, so I am waiting for some rustfmt fixes before formatting the entire repository.)

This concern is still open, isn't it? Review is made difficult by having formatting changes and actual behavior changes in the same commit.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 1, 2021

Well, I kind of do have a reason: it takes more time to build locally than to look at the CI.

from scratch I understand that, but if you have that on every build, we should look into that.

Also, you still have some compilation failures.

@RalfJung
Copy link
Member

RalfJung commented Mar 1, 2021

@henryboisdequin We described in our contributors guide how to set up an environment for local builds. If you have any questions about that, feel free to ask. :)

@henryboisdequin
Copy link
Contributor Author

this PR also removes arbitrary trailing whitespace and generally formats the affected files

This causes quite a lot of noise, which makes review harder. Can you make the formatting changes a separate commit in the PR, or (even better) create a separate format-only PR? (Please don't rustfmt the entire repository, only these two files. There are some other files where rustfmt does a bad job, so I am waiting for some rustfmt fixes before formatting the entire repository.)

This concern is still open, isn't it? Review is made difficult by having formatting changes and actual behavior changes in the same commit.

@RalfJung Do you the best way to put all the formatting changes into one commit efficently?

@RalfJung
Copy link
Member

RalfJung commented Mar 2, 2021

You could try starting with master, doing the formatting, committing that, and then rebasing the remaining changes on top of that and hope that git conflict resolution works well. There's more advanced alternatives but they are harder to explain.^^

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from d0c223e to 45d53ce Compare March 2, 2021 12:41
@henryboisdequin
Copy link
Contributor Author

@RalfJung Done, this is ready for review

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from 5d15d91 to 144dbfe Compare March 2, 2021 12:56
@oli-obk
Copy link
Contributor

oli-obk commented Mar 2, 2021

The build is still failing, maybe the rebase caused some match arms to get duplicated?

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from 144dbfe to 2f3f9d6 Compare March 2, 2021 13:23
@henryboisdequin
Copy link
Contributor Author

@oli-obk Thanks for the reminder, I was wondering why the diff was larger than before but didn't look into it 🤔

@henryboisdequin
Copy link
Contributor Author

Hmm, tests still fail @RalfJung @oli-obk. Same problem as at first

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from 487ebc4 to f0e4587 Compare March 2, 2021 14:05
@henryboisdequin henryboisdequin requested a review from oli-obk March 2, 2021 14:26
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

I think you can squash all commits after the second one into the second one, as they are just going back and forth

@henryboisdequin henryboisdequin force-pushed the add-atomic-min-and-max branch from f0e4587 to f8440d6 Compare March 2, 2021 14:47
@henryboisdequin
Copy link
Contributor Author

@oli-obk Commits squashed ✅

@oli-obk
Copy link
Contributor

oli-obk commented Mar 2, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Mar 2, 2021

📌 Commit f8440d6 has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Mar 2, 2021

⌛ Testing commit f8440d6 with merge 2670839...

@bors
Copy link
Contributor

bors commented Mar 2, 2021

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 2670839 to master...

@bors bors merged commit 2670839 into rust-lang:master Mar 2, 2021
@henryboisdequin henryboisdequin deleted the add-atomic-min-and-max branch March 2, 2021 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement atomic_min/max
4 participants