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

Change rustc_codegen_ssa's atomic_cmpxchg interface to return a pair of values #118705

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

WaffleLapkin
Copy link
Member

Doesn't change much, but a little nicer that way.

@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2023

r? @cjgillot

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

@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 7, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2023

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

Seems like it's failing because of cg_gcc tests (added back in #118463). Not sure why though.

// TODO(antoyo): handle when value is not a struct.

result.to_rvalue()
( expected.to_rvalue(), success )
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
( expected.to_rvalue(), success )
(expected.to_rvalue(), success)

@WaffleLapkin WaffleLapkin 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 10, 2023
@Urgau
Copy link
Member

Urgau commented Dec 12, 2023

Seems like it's failing because of cg_gcc tests (added back in #118463). Not sure why though.

@WaffleLapkin This has been fixed in #118706, it was a general issue with PR CI, nothing about your PR. Rebasing should be enough to fix this build issue.

@WaffleLapkin WaffleLapkin force-pushed the codegen-atomic-exhange-untuple branch 2 times, most recently from 8a5e2b9 to 0e4ccff Compare December 12, 2023 13:57
@WaffleLapkin
Copy link
Member Author

@rustbot ready

Indeed, rebase seems to have fixed ci. Thanks, @Urgau!

@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 Dec 12, 2023
@cjgillot
Copy link
Contributor

r=me with @antoyo's green light on the cg_gcc change.

@antoyo
Copy link
Contributor

antoyo commented Dec 17, 2023

I see this removed some stuff like the alignment that might still be necessary.

@WaffleLapkin: Did you run all the rustc_codegen_gcc's test suite locally (the test.sh script)?

@WaffleLapkin
Copy link
Member Author

@antoyo I don't think alignment is necessary, it was only used for the stores into the tuple temp. I did not run the tests and looking at it, they are quite cumbersome to setup, so I don't think I'll do it.

If you want to run tests yourself I suggest doing git fetch origin 0e4ccff807cce2f78ada9e3dda868bcdb419564d && git checkout 0e4ccff807cce2f78ada9e3dda868bcdb419564d. GitHub is setup in a way that you can just do that.

@antoyo
Copy link
Contributor

antoyo commented Dec 20, 2023

Ok. I'll run the whole test suite locally just to make sure.

@antoyo
Copy link
Contributor

antoyo commented Dec 20, 2023

There's this libcore test that is failing: atomic::bool_.
I'll investigate.

@antoyo
Copy link
Contributor

antoyo commented Dec 20, 2023

This might also caused by this thing that was noted and changed:

since success contains the call to the intrinsic, it must be stored before expected so that we store expected after the call.

@antoyo
Copy link
Contributor

antoyo commented Dec 20, 2023

This might also caused by this thing that was noted and changed:

since success contains the call to the intrinsic, it must be stored before expected so that we store expected after the call.

Yeah, that was it. The following code makes that test pass:

    fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool) -> (RValue<'gcc>, RValue<'gcc>) {
        let expected = self.current_func().new_local(None, cmp.get_type(), "expected");
        self.llbb().add_assignment(None, expected, cmp);
        // NOTE: gcc doesn't support a failure memory model that is stronger than the success
        // memory model.
        let order =
            if failure_order as i32 > order as i32 {
                failure_order
            }
            else {
                order
            };
        let success = self.compare_exchange(dst, expected, src, order, failure_order, weak);
 
        // NOTE: since success contains the call to the intrinsic, it must be added to the basic block before
         // expected so that we store expected after the call.
        let success_var = self.current_func().new_local(None, self.bool_type, "success");
        self.llbb().add_assignment(None, success_var, success);

        (expected.to_rvalue(), success_var.to_rvalue())
    }

I haven't ran the rest of the test suite yet.

@cjgillot cjgillot 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 23, 2023
@rust-cloud-vms rust-cloud-vms bot force-pushed the codegen-atomic-exhange-untuple branch from 0e4ccff to 6cf6139 Compare December 28, 2023 09:40
@WaffleLapkin
Copy link
Member Author

@rustbot ready

@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 Dec 28, 2023
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 28, 2023

📌 Commit 6cf6139 has been approved by cjgillot

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 Dec 28, 2023
@bors
Copy link
Contributor

bors commented Dec 28, 2023

⌛ Testing commit 6cf6139 with merge 1a147be...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 28, 2023
…untuple, r=cjgillot

Change `rustc_codegen_ssa`'s `atomic_cmpxchg` interface to return a pair of values

Doesn't change much, but a little nicer that way.
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Dec 28, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 28, 2023
@cjgillot
Copy link
Contributor

@bors retry

@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 Dec 29, 2023
@bors
Copy link
Contributor

bors commented Dec 30, 2023

⌛ Testing commit 6cf6139 with merge ddca534...

@bors
Copy link
Contributor

bors commented Dec 30, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing ddca534 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 30, 2023
@bors bors merged commit ddca534 into rust-lang:master Dec 30, 2023
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Dec 30, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ddca534): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
-1.3% [-1.7%, -1.0%] 2
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) -1.3% [-1.7%, -1.0%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.7% [-0.7%, -0.7%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 671.951s -> 669.614s (-0.35%)
Artifact size: 311.80 MiB -> 311.77 MiB (-0.01%)

@WaffleLapkin WaffleLapkin deleted the codegen-atomic-exhange-untuple branch January 2, 2024 15:05
GuillaumeGomez pushed a commit to GuillaumeGomez/rust that referenced this pull request Feb 21, 2024
…untuple, r=cjgillot

Change `rustc_codegen_ssa`'s `atomic_cmpxchg` interface to return a pair of values

Doesn't change much, but a little nicer that way.
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. 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.

9 participants