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 CFP to avoid removing synchronization #7311

Merged
merged 2 commits into from
Feb 21, 2025
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Feb 21, 2025

ConstantFieldPropagation previously reasoned that if a field has a
constant value, then it is not possible for release-acquire operations
to use it for synchronization, since the read can be assumed to be from
a previous write. This logic was incorrect because reads must read the
value written by the last write in the global modification order for the
accessed location.

In principle it would be possible for CFP to detect fields that have
both constant values and also either no acquire reads or no release
writes. Such fields cannot possibly be part of synchronization edges and
their gets could be optimized normally. For now though, simply do not
optimize any gets with acquire or seqcst ordering. Similarly, stop
optimizing RMW operations because they can also form synchronization
edges.

ConstantFieldPropagation previously reasoned that if a field has a
constant value, then it is not possible for release-acquire operations
to use it for synchronization, since the read can be assumed to be from
a previous write. This logic was incorrect because reads must read the
value written by the last write in the global modification order for the
accessed location.

In principle it would be possible for CFP to detect fields that have
both constant values and also either no acquire reads or no release
writes. Such fields cannot possibly be part of synchronization edges and
their gets could be optimized normally. For now though, simply do not
optimize any gets with acquire or seqcst ordering. Similarly, stop
optimizing RMW operations because they can also form synchronization
edges.
@tlively tlively requested a review from kripken February 21, 2025 00:55
// final type can be fairly fast (perhaps constant time). We therefore
// look if one of the sets of types contains a single type and it is
// final, and if so then we'll test on it. (However, see a few lines below
// on how we test for finality.)
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change? It was 80-column conformant already.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, hmm, I had accidentally added some random characters in the middle of a word here. I removed them and reformatted, but I guess the formatter kept the line breaks from before I had removed them. Will fix.

Comment on lines 275 to 276
;; This cmpxchg copies the field, so does not change the value. It can still
;; not be optimized.
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
;; This cmpxchg copies the field, so does not change the value. It can still
;; not be optimized.
;; This cmpxchg copies the field, so does not change the value. It still
;; cannot be optimized.

@tlively tlively merged commit 54abcfe into main Feb 21, 2025
14 checks passed
@tlively tlively deleted the fix-cfp-synchronization branch February 21, 2025 18:57
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.

2 participants