Index: llvm/include/llvm/Analysis/TargetTransformInfo.h =================================================================== --- llvm/include/llvm/Analysis/TargetTransformInfo.h +++ llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -233,31 +233,6 @@ /// the EXT operation. int getExtCost(const Instruction *I, const Value *Src) const; - /// Estimate the cost of a function call when lowered. - /// - /// The contract for this is the same as \c getOperationCost except that it - /// supports an interface that provides extra information specific to call - /// instructions. - /// - /// This is the most basic query for estimating call cost: it only knows the - /// function type and (potentially) the number of arguments at the call site. - /// The latter is only interesting for varargs function types. - int getCallCost(FunctionType *FTy, int NumArgs = -1, - const User *U = nullptr) const; - - /// Estimate the cost of calling a specific function when lowered. - /// - /// This overload adds the ability to reason about the particular function - /// being called in the event it is a library call with special lowering. - int getCallCost(const Function *F, int NumArgs = -1, - const User *U = nullptr) const; - - /// Estimate the cost of calling a specific function when lowered. - /// - /// This overload allows specifying a set of candidate argument values. - int getCallCost(const Function *F, ArrayRef Arguments, - const User *U = nullptr) const; - /// \returns A value by which our inlining threshold should be multiplied. /// This is primarily used to bump up the inlining threshold wholesale on /// targets where calls are unusually expensive. @@ -279,15 +254,11 @@ int getInlinerVectorBonusPercent() const; /// Estimate the cost of an intrinsic when lowered. - /// - /// Mirrors the \c getCallCost method but uses an intrinsic identifier. int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, ArrayRef ParamTys, const User *U = nullptr) const; /// Estimate the cost of an intrinsic when lowered. - /// - /// Mirrors the \c getCallCost method but uses an intrinsic identifier. int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, ArrayRef Arguments, const User *U = nullptr) const; @@ -1206,10 +1177,6 @@ virtual int getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef Operands) = 0; virtual int getExtCost(const Instruction *I, const Value *Src) = 0; - virtual int getCallCost(FunctionType *FTy, int NumArgs, const User *U) = 0; - virtual int getCallCost(const Function *F, int NumArgs, const User *U) = 0; - virtual int getCallCost(const Function *F, - ArrayRef Arguments, const User *U) = 0; virtual unsigned getInliningThresholdMultiplier() = 0; virtual int getInlinerVectorBonusPercent() = 0; virtual int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, @@ -1455,16 +1422,6 @@ int getExtCost(const Instruction *I, const Value *Src) override { return Impl.getExtCost(I, Src); } - int getCallCost(FunctionType *FTy, int NumArgs, const User *U) override { - return Impl.getCallCost(FTy, NumArgs, U); - } - int getCallCost(const Function *F, int NumArgs, const User *U) override { - return Impl.getCallCost(F, NumArgs, U); - } - int getCallCost(const Function *F, - ArrayRef Arguments, const User *U) override { - return Impl.getCallCost(F, Arguments, U); - } unsigned getInliningThresholdMultiplier() override { return Impl.getInliningThresholdMultiplier(); } Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -132,21 +132,6 @@ return TTI::TCC_Basic; } - unsigned getCallCost(FunctionType *FTy, int NumArgs, const User *U) { - assert(FTy && "FunctionType must be provided to this routine."); - - // The target-independent implementation just measures the size of the - // function by approximating that each argument will take on average one - // instruction to prepare. - - if (NumArgs < 0) - // Set the argument number to the number of explicit arguments in the - // function. - NumArgs = FTy->getNumParams(); - - return TTI::TCC_Basic * (NumArgs + 1); - } - unsigned getInliningThresholdMultiplier() { return 1; } int getInlinerVectorBonusPercent() { return 150; } @@ -726,37 +711,6 @@ explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {} public: - using BaseT::getCallCost; - - unsigned getCallCost(const Function *F, int NumArgs, const User *U) { - assert(F && "A concrete function must be provided to this routine."); - - if (NumArgs < 0) - // Set the argument number to the number of explicit arguments in the - // function. - NumArgs = F->arg_size(); - - if (Intrinsic::ID IID = F->getIntrinsicID()) { - FunctionType *FTy = F->getFunctionType(); - SmallVector ParamTys(FTy->param_begin(), FTy->param_end()); - return static_cast(this) - ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U); - } - - if (!static_cast(this)->isLoweredToCall(F)) - return TTI::TCC_Basic; // Give a basic cost if it will be lowered - // directly. - - return static_cast(this)->getCallCost(F->getFunctionType(), NumArgs, U); - } - - unsigned getCallCost(const Function *F, ArrayRef Arguments, - const User *U) { - // Simply delegate to generic handling of the call. - // FIXME: We should use instsimplify or something else to catch calls which - // will constant fold with these arguments. - return static_cast(this)->getCallCost(F, Arguments.size(), U); - } using BaseT::getGEPCost; @@ -898,15 +852,19 @@ if (auto CS = ImmutableCallSite(U)) { const Function *F = CS.getCalledFunction(); - if (!F) { - // Just use the called value type. - Type *FTy = CS.getCalledValue()->getType()->getPointerElementType(); - return TargetTTI->getCallCost(cast(FTy), - CS.arg_size(), U); - } + if (F) { + FunctionType *FTy = F->getFunctionType(); + if (Intrinsic::ID IID = F->getIntrinsicID()) { + SmallVector ParamTys(FTy->param_begin(), FTy->param_end()); + return TargetTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U); + } - SmallVector Arguments(CS.arg_begin(), CS.arg_end()); - return TargetTTI->getCallCost(F, Arguments, U); + if (!TargetTTI->isLoweredToCall(F)) + return TTI::TCC_Basic; // Give a basic cost if it will be lowered + + return TTI::TCC_Basic * (FTy->getNumParams() + 1); + } + return TTI::TCC_Basic * (CS.arg_size() + 1); } if (isa(U) || isa(U) || isa(U)) Index: llvm/lib/Analysis/TargetTransformInfo.cpp =================================================================== --- llvm/lib/Analysis/TargetTransformInfo.cpp +++ llvm/lib/Analysis/TargetTransformInfo.cpp @@ -153,21 +153,6 @@ return Cost; } -int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs, - const User *U) const { - int Cost = TTIImpl->getCallCost(FTy, NumArgs, U); - assert(Cost >= 0 && "TTI should not produce negative costs!"); - return Cost; -} - -int TargetTransformInfo::getCallCost(const Function *F, - ArrayRef Arguments, - const User *U) const { - int Cost = TTIImpl->getCallCost(F, Arguments, U); - assert(Cost >= 0 && "TTI should not produce negative costs!"); - return Cost; -} - unsigned TargetTransformInfo::getInliningThresholdMultiplier() const { return TTIImpl->getInliningThresholdMultiplier(); }