diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/IR/Instructions.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/IR/Module.cpp | 13 |
3 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 6af0589f9cc..574ca88e1c9 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1018,9 +1018,10 @@ bool Intrinsic::isLeaf(ID id) { Function *Intrinsic::getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys) { // There can never be multiple globals with the same name of different types, // because intrinsics must be a specific type. - return - cast<Function>(M->getOrInsertFunction(getName(id, Tys), - getType(M->getContext(), id, Tys))); + return cast<Function>( + M->getOrInsertFunction(getName(id, Tys), + getType(M->getContext(), id, Tys)) + .getCallee()); } // This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method. diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 6c7817adc6a..4819d5f7b7d 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -517,7 +517,7 @@ static Instruction *createMalloc(Instruction *InsertBefore, BasicBlock *BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd; Module *M = BB->getParent()->getParent(); Type *BPTy = Type::getInt8PtrTy(BB->getContext()); - Value *MallocFunc = MallocF; + FunctionCallee MallocFunc = MallocF; if (!MallocFunc) // prototype malloc as "void *malloc(size_t)" MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy); @@ -541,7 +541,7 @@ static Instruction *createMalloc(Instruction *InsertBefore, } } MCall->setTailCall(); - if (Function *F = dyn_cast<Function>(MallocFunc)) { + if (Function *F = dyn_cast<Function>(MallocFunc.getCallee())) { MCall->setCallingConv(F->getCallingConv()); if (!F->returnDoesNotAlias()) F->setReturnDoesNotAlias(); @@ -614,7 +614,7 @@ static Instruction *createFree(Value *Source, Type *VoidTy = Type::getVoidTy(M->getContext()); Type *IntPtrTy = Type::getInt8PtrTy(M->getContext()); // prototype free as "void free(void*)" - Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy); + FunctionCallee FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy); CallInst *Result = nullptr; Value *PtrCast = Source; if (InsertBefore) { @@ -627,7 +627,7 @@ static Instruction *createFree(Value *Source, Result = CallInst::Create(FreeFunc, PtrCast, Bundles, ""); } Result->setTailCall(); - if (Function *F = dyn_cast<Function>(FreeFunc)) + if (Function *F = dyn_cast<Function>(FreeFunc.getCallee())) Result->setCallingConv(F->getCallingConv()); return Result; diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index fd6495f4dbd..b6dd7ab70a8 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -140,8 +140,8 @@ void Module::getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const { // it. This is nice because it allows most passes to get away with not handling // the symbol table directly for this common task. // -Constant *Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, - AttributeList AttributeList) { +FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, + AttributeList AttributeList) { // See if we have a definition for the specified function already. GlobalValue *F = getNamedValue(Name); if (!F) { @@ -151,21 +151,20 @@ Constant *Module::getOrInsertFunction(StringRef Name, FunctionType *Ty, if (!New->isIntrinsic()) // Intrinsics get attrs set on construction New->setAttributes(AttributeList); FunctionList.push_back(New); - return New; // Return the new prototype. + return {Ty, New}; // Return the new prototype. } // If the function exists but has the wrong type, return a bitcast to the // right type. auto *PTy = PointerType::get(Ty, F->getAddressSpace()); if (F->getType() != PTy) - return ConstantExpr::getBitCast(F, PTy); + return {Ty, ConstantExpr::getBitCast(F, PTy)}; // Otherwise, we just found the existing function or a prototype. - return F; + return {Ty, F}; } -Constant *Module::getOrInsertFunction(StringRef Name, - FunctionType *Ty) { +FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty) { return getOrInsertFunction(Name, Ty, AttributeList()); } |