diff options
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp index 0c56927dea02b..4a14259f1bdb1 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp @@ -32,7 +32,6 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetOptions.h" #include <cmath> #include <vector> @@ -170,16 +169,13 @@ namespace { class AMDGPUSimplifyLibCalls : public FunctionPass { - const TargetOptions Options; - AMDGPULibCalls Simplifier; public: static char ID; // Pass identification - AMDGPUSimplifyLibCalls(const TargetOptions &Opt = TargetOptions(), - const TargetMachine *TM = nullptr) - : FunctionPass(ID), Options(Opt), Simplifier(TM) { + AMDGPUSimplifyLibCalls(const TargetMachine *TM = nullptr) + : FunctionPass(ID), Simplifier(TM) { initializeAMDGPUSimplifyLibCallsPass(*PassRegistry::getPassRegistry()); } @@ -585,7 +581,7 @@ bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, assert(Callee->hasName() && "Invalid read_pipe/write_pipe function"); auto *M = Callee->getParent(); auto &Ctx = M->getContext(); - std::string Name = Callee->getName(); + std::string Name = std::string(Callee->getName()); auto NumArg = CI->getNumArgOperands(); if (NumArg != 4 && NumArg != 6) return false; @@ -594,15 +590,15 @@ bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, if (!isa<ConstantInt>(PacketSize) || !isa<ConstantInt>(PacketAlign)) return false; unsigned Size = cast<ConstantInt>(PacketSize)->getZExtValue(); - unsigned Align = cast<ConstantInt>(PacketAlign)->getZExtValue(); - if (Size != Align || !isPowerOf2_32(Size)) + Align Alignment = cast<ConstantInt>(PacketAlign)->getAlignValue(); + if (Alignment != Size) return false; Type *PtrElemTy; if (Size <= 8) PtrElemTy = Type::getIntNTy(Ctx, Size * 8); else - PtrElemTy = VectorType::get(Type::getInt64Ty(Ctx), Size / 8); + PtrElemTy = FixedVectorType::get(Type::getInt64Ty(Ctx), Size / 8); unsigned PtrArgLoc = CI->getNumArgOperands() - 3; auto PtrArg = CI->getArgOperand(PtrArgLoc); unsigned PtrArgAS = PtrArg->getType()->getPointerAddressSpace(); @@ -1130,8 +1126,8 @@ bool AMDGPULibCalls::fold_pow(CallInst *CI, IRBuilder<> &B, Type* rTy = opr0->getType(); Type* nTyS = eltType->isDoubleTy() ? B.getInt64Ty() : B.getInt32Ty(); Type *nTy = nTyS; - if (const VectorType *vTy = dyn_cast<VectorType>(rTy)) - nTy = VectorType::get(nTyS, vTy->getNumElements()); + if (const auto *vTy = dyn_cast<FixedVectorType>(rTy)) + nTy = FixedVectorType::get(nTyS, vTy); unsigned size = nTy->getScalarSizeInBits(); opr_n = CI->getArgOperand(1); if (opr_n->getType()->isIntegerTy()) @@ -1420,8 +1416,8 @@ AllocaInst* AMDGPULibCalls::insertAlloca(CallInst *UI, IRBuilder<> &B, B.SetInsertPoint(&*ItNew); AllocaInst *Alloc = B.CreateAlloca(RetType, 0, std::string(prefix) + UI->getName()); - Alloc->setAlignment(MaybeAlign( - UCallee->getParent()->getDataLayout().getTypeAllocSize(RetType))); + Alloc->setAlignment( + Align(UCallee->getParent()->getDataLayout().getTypeAllocSize(RetType))); return Alloc; } @@ -1711,35 +1707,14 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, FuncInfo &FInfo) { } // Public interface to the Simplify LibCalls pass. -FunctionPass *llvm::createAMDGPUSimplifyLibCallsPass(const TargetOptions &Opt, - const TargetMachine *TM) { - return new AMDGPUSimplifyLibCalls(Opt, TM); +FunctionPass *llvm::createAMDGPUSimplifyLibCallsPass(const TargetMachine *TM) { + return new AMDGPUSimplifyLibCalls(TM); } FunctionPass *llvm::createAMDGPUUseNativeCallsPass() { return new AMDGPUUseNativeCalls(); } -static bool setFastFlags(Function &F, const TargetOptions &Options) { - AttrBuilder B; - - if (Options.UnsafeFPMath || Options.NoInfsFPMath) - B.addAttribute("no-infs-fp-math", "true"); - if (Options.UnsafeFPMath || Options.NoNaNsFPMath) - B.addAttribute("no-nans-fp-math", "true"); - if (Options.UnsafeFPMath) { - B.addAttribute("less-precise-fpmad", "true"); - B.addAttribute("unsafe-fp-math", "true"); - } - - if (!B.hasAttributes()) - return false; - - F.addAttributes(AttributeList::FunctionIndex, B); - - return true; -} - bool AMDGPUSimplifyLibCalls::runOnFunction(Function &F) { if (skipFunction(F)) return false; @@ -1750,15 +1725,14 @@ bool AMDGPUSimplifyLibCalls::runOnFunction(Function &F) { LLVM_DEBUG(dbgs() << "AMDIC: process function "; F.printAsOperand(dbgs(), false, F.getParent()); dbgs() << '\n';); - if (!EnablePreLink) - Changed |= setFastFlags(F, Options); - for (auto &BB : F) { for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ) { // Ignore non-calls. CallInst *CI = dyn_cast<CallInst>(I); ++I; - if (!CI) continue; + // Ignore intrinsics that do not become real instructions. + if (!CI || isa<DbgInfoIntrinsic>(CI) || CI->isLifetimeStartOrEnd()) + continue; // Ignore indirect calls. Function *Callee = CI->getCalledFunction(); |