[llvm] 2641a19 - [TTI] Remove getCallCost
Sam Parker via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 01:05:56 PDT 2020
Author: Sam Parker
Date: 2020-04-01T09:05:25+01:00
New Revision: 2641a19981e71c887bece92074e00d1af3e716c9
URL: https://github.com/llvm/llvm-project/commit/2641a19981e71c887bece92074e00d1af3e716c9
DIFF: https://github.com/llvm/llvm-project/commit/2641a19981e71c887bece92074e00d1af3e716c9.diff
LOG: [TTI] Remove getCallCost
getCallCost is only used within the different layers of TTI, with no
backend implementing it so fold the base implementation into
getUserCost. I think this is an NFC.
Differential Revision: https://reviews.llvm.org/D77050
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index ce04592bf53e..5f5ef62f0139 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -233,31 +233,6 @@ class TargetTransformInfo {
/// 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<const Value *> 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 @@ class TargetTransformInfo {
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<Type *> 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<const Value *> Arguments,
const User *U = nullptr) const;
@@ -1206,10 +1177,6 @@ class TargetTransformInfo::Concept {
virtual int getGEPCost(Type *PointeeType, const Value *Ptr,
ArrayRef<const Value *> 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<const Value *> 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 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
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<const Value *> Arguments, const User *U) override {
- return Impl.getCallCost(F, Arguments, U);
- }
unsigned getInliningThresholdMultiplier() override {
return Impl.getInliningThresholdMultiplier();
}
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 765d35a05a46..8749fa49010b 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -132,21 +132,6 @@ class TargetTransformInfoImplBase {
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 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
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<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
- return static_cast<T *>(this)
- ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
- }
-
- if (!static_cast<T *>(this)->isLoweredToCall(F))
- return TTI::TCC_Basic; // Give a basic cost if it will be lowered
- // directly.
-
- return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
- }
-
- unsigned getCallCost(const Function *F, ArrayRef<const Value *> 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<T *>(this)->getCallCost(F, Arguments.size(), U);
- }
using BaseT::getGEPCost;
@@ -898,15 +852,19 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
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<FunctionType>(FTy),
- CS.arg_size(), U);
- }
+ if (F) {
+ FunctionType *FTy = F->getFunctionType();
+ if (Intrinsic::ID IID = F->getIntrinsicID()) {
+ SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
+ return TargetTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
+ }
- SmallVector<const Value *, 8> 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<SExtInst>(U) || isa<ZExtInst>(U) || isa<FPExtInst>(U))
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 2ae44caaaa32..a240571a39da 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -153,21 +153,6 @@ int TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
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<const Value *> 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();
}
More information about the llvm-commits
mailing list