Skip to content

Commit 01fd0fa

Browse files
committed
[LLVM-C] Allow LLVMGetVolatile to work with any kind of Instruction
1 parent fd7aae3 commit 01fd0fa

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Changes to the C API
147147
--------------------
148148

149149
* Add `LLVMGetOrInsertFunction` to get or insert a function, replacing the combination of `LLVMGetNamedFunction` and `LLVMAddFunction`.
150+
* Allow `LLVMGetVolatile` to work with any kind of Instruction.
150151

151152
Changes to the CodeGen infrastructure
152153
-------------------------------------

llvm/include/llvm-c/Core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4757,7 +4757,7 @@ LLVM_C_ABI LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
47574757
LLVM_C_ABI LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B,
47584758
const char *Str,
47594759
const char *Name);
4760-
LLVM_C_ABI LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
4760+
LLVM_C_ABI LLVMBool LLVMGetVolatile(LLVMValueRef Inst);
47614761
LLVM_C_ABI void LLVMSetVolatile(LLVMValueRef MemoryAccessInst,
47624762
LLVMBool IsVolatile);
47634763
LLVM_C_ABI LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);

llvm/lib/IR/Core.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,15 +4098,8 @@ LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
40984098
return wrap(unwrap(B)->CreateGlobalString(Str, Name));
40994099
}
41004100

4101-
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst) {
4102-
Value *P = unwrap(MemAccessInst);
4103-
if (LoadInst *LI = dyn_cast<LoadInst>(P))
4104-
return LI->isVolatile();
4105-
if (StoreInst *SI = dyn_cast<StoreInst>(P))
4106-
return SI->isVolatile();
4107-
if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
4108-
return AI->isVolatile();
4109-
return cast<AtomicCmpXchgInst>(P)->isVolatile();
4101+
LLVMBool LLVMGetVolatile(LLVMValueRef Inst) {
4102+
return cast<Instruction>(unwrap(Inst))->isVolatile();
41104103
}
41114104

41124105
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {

0 commit comments

Comments
 (0)