Skip to content

Commit

Permalink
Make LLVMIsAtomicSingleThread and LLVMGetAtomicSyncScopeID work on no…
Browse files Browse the repository at this point in the history
…n-atomic instructions.
  • Loading branch information
maleadt committed Aug 19, 2024
1 parent 0028d86 commit 88b495d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions llvm/lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4369,12 +4369,14 @@ int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
int LLVMGetUndefMaskElem(void) { return PoisonMaskElem; }

LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) {
return getAtomicSyncScopeID(unwrap<Instruction>(AtomicInst)).value() ==
SyncScope::SingleThread;
Instruction *I = unwrap<Instruction>(AtomicInst);
if (!I->isAtomic())
return 0;
return getAtomicSyncScopeID(I).value() == SyncScope::SingleThread;
}

unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst) {
return getAtomicSyncScopeID(unwrap<Instruction>(AtomicInst)).value();
return getAtomicSyncScopeID(unwrap<Instruction>(AtomicInst)).value_or(-1);
}

void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue) {
Expand Down

0 comments on commit 88b495d

Please sign in to comment.