diff options
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp index e01c9dc66a3f..cf8b416d23e5 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp @@ -20,11 +20,8 @@ #include "llvm/IR/AttributeMask.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/IR/IntrinsicInst.h" -#include "llvm/IR/IntrinsicsAMDGPU.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/PatternMatch.h" -#include "llvm/InitializePasses.h" #include <cmath> #define DEBUG_TYPE "amdgpu-simplifylib" @@ -657,7 +654,7 @@ bool AMDGPULibCalls::fold(CallInst *CI) { // Further check the number of arguments to see if they match. // TODO: Check calling convention matches too - if (!FInfo.isCompatibleSignature(CI->getFunctionType())) + if (!FInfo.isCompatibleSignature(*Callee->getParent(), CI->getFunctionType())) return false; LLVM_DEBUG(dbgs() << "AMDIC: try folding " << *CI << '\n'); @@ -753,7 +750,7 @@ bool AMDGPULibCalls::fold(CallInst *CI) { CI->setArgOperand(1, SplatArg1); } - CI->setCalledFunction(Intrinsic::getDeclaration( + CI->setCalledFunction(Intrinsic::getOrInsertDeclaration( CI->getModule(), Intrinsic::ldexp, {CI->getType(), CI->getArgOperand(1)->getType()})); return true; @@ -788,7 +785,8 @@ bool AMDGPULibCalls::fold(CallInst *CI) { B.CreateFPToSI(FPOp->getOperand(1), PownType->getParamType(1)); // Have to drop any nofpclass attributes on the original call site. Call->removeParamAttrs( - 1, AttributeFuncs::typeIncompatible(CastedArg->getType())); + 1, AttributeFuncs::typeIncompatible(CastedArg->getType(), + Call->getParamAttributes(1))); Call->setCalledFunction(PownFunc); Call->setArgOperand(1, CastedArg); return fold_pow(FPOp, B, PownInfo) || true; @@ -1034,7 +1032,8 @@ bool AMDGPULibCalls::fold_pow(FPMathOperator *FPOp, IRBuilder<> &B, // pown/pow ---> powr(fabs(x), y) | (x & ((int)y << 31)) FunctionCallee ExpExpr; if (ShouldUseIntrinsic) - ExpExpr = Intrinsic::getDeclaration(M, Intrinsic::exp2, {FPOp->getType()}); + ExpExpr = Intrinsic::getOrInsertDeclaration(M, Intrinsic::exp2, + {FPOp->getType()}); else { ExpExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_EXP2, FInfo)); if (!ExpExpr) @@ -1108,8 +1107,8 @@ bool AMDGPULibCalls::fold_pow(FPMathOperator *FPOp, IRBuilder<> &B, if (needlog) { FunctionCallee LogExpr; if (ShouldUseIntrinsic) { - LogExpr = - Intrinsic::getDeclaration(M, Intrinsic::log2, {FPOp->getType()}); + LogExpr = Intrinsic::getOrInsertDeclaration(M, Intrinsic::log2, + {FPOp->getType()}); } else { LogExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_LOG2, FInfo)); if (!LogExpr) @@ -1298,8 +1297,8 @@ void AMDGPULibCalls::replaceLibCallWithSimpleIntrinsic(IRBuilder<> &B, } } - CI->setCalledFunction( - Intrinsic::getDeclaration(CI->getModule(), IntrID, {CI->getType()})); + CI->setCalledFunction(Intrinsic::getOrInsertDeclaration( + CI->getModule(), IntrID, {CI->getType()})); } bool AMDGPULibCalls::tryReplaceLibcallWithSimpleIntrinsic( |
