Skip to content

[XCore] Set MaxAtomicSizeInBitsSupported to 0 #74389

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
Dec 5, 2023

Conversation

jyknight
Copy link
Member

@jyknight jyknight commented Dec 4, 2023

XCore does not appear to have any support for atomicrmw or cmpxchg.

This will result in all atomic operations getting expanded to _atomic* libcalls via AtomicExpandPass, which matches what Clang already does in the frontend.

Additionally, remove the code which handles atomic load/store, as it will no longer be used.

XCore does not appear to have any support for atomicrmw or cmpxchg.

This will result in all atomic operations getting expanded to
__atomic_* libcalls via AtomicExpandPass, which matches what Clang
already does in the frontend.

Additionally, remove the code which handles atomic load/store, as it
will no longer be used.
@jyknight jyknight requested a review from nigelp-xmos December 4, 2023 23:46
Copy link

github-actions bot commented Dec 4, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@nigelp-xmos nigelp-xmos left a comment

Choose a reason for hiding this comment

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

That's correct that XCore does not have atomicrmw or cmpxchg. It lowered aligned atomic load & store because under its hardware memory model they would be inherently atomic.

To check my understanding: within the max bits, we are expected to support all five atomic instructions. So currently aligned 4-byte atomicrmw (for example) crashes with isel error. But unaligned operations will already go to library. So if atomicrmw etc are not supported, load & store cannot be either.

Just to mention, while looking at this, I noticed that TargetLoweringBase.cpp has the comment that the default will be set to 0 - just wondered if that's still the case.

@jyknight
Copy link
Member Author

jyknight commented Dec 5, 2023

within the max bits, we are expected to support all five atomic instructions

Correct: if native lockless implementations for all 5 operations aren't available for a given size, then it's required to fallback to the _atomic* library routine for all of them. The library may use a lock-based implementation, and unless all the operations go through the library, it isn't possible to guarantee that e.g. cmpxchg vs store are atomic.

Just to mention, while looking at this, I noticed that TargetLoweringBase.cpp has the comment that the default will be set to 0 - just wondered if that's still the case.

Yes, that was a migration I started, then dropped on the floor for ... a few years, sorry. This is me picking that back up. First step is to fix all in-tree targets explicitly, and will change the default afterwards.

@jyknight jyknight merged commit 020746d into llvm:main Dec 5, 2023
@jyknight jyknight deleted the atomic-max-xcore branch December 5, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants