diff options
Diffstat (limited to 'llvm/lib/IR/Core.cpp')
| -rw-r--r-- | llvm/lib/IR/Core.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 8b5965ba45a6..27d8294b0126 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -2403,6 +2403,14 @@ LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, GlobalValue::ExternalLinkage, Name, unwrap(M))); } +LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M, const char *Name, + size_t NameLen, LLVMTypeRef FunctionTy) { + return wrap(unwrap(M) + ->getOrInsertFunction(StringRef(Name, NameLen), + unwrap<FunctionType>(FunctionTy)) + .getCallee()); +} + LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name) { return wrap(unwrap(M)->getFunction(Name)); } @@ -2994,6 +3002,8 @@ LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst) { LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst) { Instruction *Instr = unwrap<Instruction>(Inst); + if (!Instr->DebugMarker) + return nullptr; auto I = Instr->DebugMarker->StoredDbgRecords.begin(); if (I == Instr->DebugMarker->StoredDbgRecords.end()) return nullptr; @@ -3002,6 +3012,8 @@ LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst) { LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst) { Instruction *Instr = unwrap<Instruction>(Inst); + if (!Instr->DebugMarker) + return nullptr; auto I = Instr->DebugMarker->StoredDbgRecords.rbegin(); if (I == Instr->DebugMarker->StoredDbgRecords.rend()) return nullptr; @@ -4086,15 +4098,8 @@ LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, return wrap(unwrap(B)->CreateGlobalString(Str, Name)); } -LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst) { - Value *P = unwrap(MemAccessInst); - if (LoadInst *LI = dyn_cast<LoadInst>(P)) - return LI->isVolatile(); - if (StoreInst *SI = dyn_cast<StoreInst>(P)) - return SI->isVolatile(); - if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P)) - return AI->isVolatile(); - return cast<AtomicCmpXchgInst>(P)->isVolatile(); +LLVMBool LLVMGetVolatile(LLVMValueRef Inst) { + return cast<Instruction>(unwrap(Inst))->isVolatile(); } void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) { |
