[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
Mon Aug 19 07:19:42 PDT 2024


================
@@ -4336,25 +4386,29 @@ int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
 
 int LLVMGetUndefMaskElem(void) { return PoisonMaskElem; }
 
-LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) {
-  Value *P = unwrap(AtomicInst);
-
+static unsigned getAtomicSyncScopeID(Value *P) {
   if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
-    return I->getSyncScopeID() == SyncScope::SingleThread;
+    return I->getSyncScopeID();
   else if (FenceInst *FI = dyn_cast<FenceInst>(P))
-    return FI->getSyncScopeID() == SyncScope::SingleThread;
+    return FI->getSyncScopeID();
   else if (StoreInst *SI = dyn_cast<StoreInst>(P))
-    return SI->getSyncScopeID() == SyncScope::SingleThread;
+    return SI->getSyncScopeID();
   else if (LoadInst *LI = dyn_cast<LoadInst>(P))
-    return LI->getSyncScopeID() == SyncScope::SingleThread;
-  return cast<AtomicCmpXchgInst>(P)->getSyncScopeID() ==
-             SyncScope::SingleThread;
+    return LI->getSyncScopeID();
+  return cast<AtomicCmpXchgInst>(P)->getSyncScopeID();
----------------
nikic wrote:

This is basically re-inventing getAtomicSyncScopeID() from Instructions.h.

https://github.com/llvm/llvm-project/pull/104775


More information about the llvm-commits mailing list