[llvm] [LLVM] Add a C API for creating instructions with custom syncscopes. (PR #104775)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 03:20:15 PDT 2024
================
@@ -4942,6 +4942,25 @@ inline std::optional<SyncScope::ID> getAtomicSyncScopeID(const Instruction *I) {
llvm_unreachable("unhandled atomic operation");
}
+/// A helper function that sets an atomic operation's sync scope.
+/// Does nothing if it is not an atomic operation.
+inline void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID) {
+ if (!I->isAtomic())
----------------
nikic wrote:
I think I'd prefer an `assert(I->isAtomic())` here. Silently discarding a set seems like a bad idea. The caller can do an isAtomic() check if it wants that behavior.
https://github.com/llvm/llvm-project/pull/104775
More information about the llvm-commits
mailing list