Repository navigation
cranelift: reject big-endian atomic_cas.i128 on x64 - #15464
Open
larancibia wants to merge 1 commit into
Open
larancibia wants to merge 1 commit into
larancibia wants to merge 1 commit into
Conversation
The x64 ISLE lowering rule for `atomic_cas` on `i128` matched `(mem_flags_data flags)` instead of `(little_or_native_endian flags)`, so big-endian `atomic_cas.i128` silently lowered to a little-endian `lock cmpxchg16b` instead of failing compilation like the other x64 atomic rules. Switch the rule to `(little_or_native_endian flags)` and add `atomic_cas.i64` and `atomic_cas.i128` cases to x64 `big-endian.clif` (enabling `has_cmpxchg16b` on the target line so the `i128` test exercises the endianness guard rather than failing on the feature check).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The x64 lowering rule for
atomic_cas.i128incranelift/codegen/src/isa/x64/lower.islematched(mem_flags_data flags)instead of(little_or_native_endian flags). Unlike thefits_in_64atomic_casrule right above it and the other x64 atomic lowering rules (atomic_load,atomic_store,atomic_rmw), this letatomic_cas.i128 bigcompile silently into a little-endianlock cmpxchg16bwithout byte-swapping.This switches the rule to
(little_or_native_endian flags)and addsatomic_cas.i64andatomic_cas.i128cases tocranelift/filetests/filetests/isa/x64/big-endian.clif(enablinghas_cmpxchg16bon the target line so thei128case exercises the endianness check rather than failing on the CPU feature check).Tested locally with:
clif-util test cranelift/filetests/filetests/isa/x64/big-endian.clif(failed before the fix withExpected compilation failure but compilation succeeded, passes after)clif-util test cranelift/filetests/filetests/isa/x64/atomic-*.clif cranelift/filetests/filetests/isa/x64/atomic_cas_const_addr.clif