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

[CIR] Atomic builtins with non-const memory order #736

Merged
merged 4 commits into from
Jul 15, 2024

Conversation

dkolsen-pgi
Copy link
Collaborator

Fix #731

Implement atomic built-in operations where the memory order argument is a runtime value rather than a compile-time constant. This is necessary to support std::atomic. The ClangIR atomic operations don't support runtime memory orders, so this is implemented during CodeGen by generating a switch statement that effectively converts the runtime memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests to cover this situation.

Fix llvm#731

Implement atomic built-in operations where the memory order argument is
a runtime value rather than a compile-time constant.  This is necessary
to support std::atomic.  The ClangIR atomic operations don't support
runtime memory orders, so this is implemented during CodeGen by
generating a switch statement that effectively converts the runtime
memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests
to cover this situation.
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Great, some minor changes and should be good. Thanks for fixing this

clang/lib/CIR/CodeGen/CIRGenAtomic.cpp Outdated Show resolved Hide resolved
clang/test/CIR/CodeGen/atomic-runtime.cpp Show resolved Hide resolved
This is the response to code review comments for PR llvm#736.

Don't use `auto` declarations in a couple places.

Add a test for LLVM lowering of atomic_load_n with a non-const memory
order.
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Approved too fast, some minor nit remaining.

clang/test/CIR/Lowering/atomic-runtime.cpp Outdated Show resolved Hide resolved
Change the lowering test atomic-runtime.cpp to check the LLVM IR rather
than the LLVM MLIR dialect.  LLVM IR will be more stable over time.
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Great, LGTM

@bcardosolopes bcardosolopes merged commit a944884 into llvm:main Jul 15, 2024
6 checks passed
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
Fix llvm#731

Implement atomic built-in operations where the memory order argument is
a runtime value rather than a compile-time constant. This is necessary
to support `std::atomic`. The ClangIR atomic operations don't support
runtime memory orders, so this is implemented during CodeGen by
generating a switch statement that effectively converts the runtime
memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests
to cover this situation.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
Fix llvm#731

Implement atomic built-in operations where the memory order argument is
a runtime value rather than a compile-time constant. This is necessary
to support `std::atomic`. The ClangIR atomic operations don't support
runtime memory orders, so this is implemented during CodeGen by
generating a switch statement that effectively converts the runtime
memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests
to cover this situation.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
Fix llvm#731

Implement atomic built-in operations where the memory order argument is
a runtime value rather than a compile-time constant. This is necessary
to support `std::atomic`. The ClangIR atomic operations don't support
runtime memory orders, so this is implemented during CodeGen by
generating a switch statement that effectively converts the runtime
memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests
to cover this situation.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
Fix llvm#731

Implement atomic built-in operations where the memory order argument is
a runtime value rather than a compile-time constant. This is necessary
to support `std::atomic`. The ClangIR atomic operations don't support
runtime memory orders, so this is implemented during CodeGen by
generating a switch statement that effectively converts the runtime
memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests
to cover this situation.
lanza pushed a commit that referenced this pull request Nov 5, 2024
Fix #731

Implement atomic built-in operations where the memory order argument is
a runtime value rather than a compile-time constant. This is necessary
to support `std::atomic`. The ClangIR atomic operations don't support
runtime memory orders, so this is implemented during CodeGen by
generating a switch statement that effectively converts the runtime
memory order into a compile-time memory order.

A new file, atomic-runtime.cpp, was added to the ClangIR CodeGen tests
to cover this situation.
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.

Non-constant memory order in atomic built-ins
2 participants