Skip to content

Commit 2641a19

Browse files
committed
[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
1 parent f92563f commit 2641a19

File tree

3 files changed

+12
-112
lines changed

3 files changed

+12
-112
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -233,31 +233,6 @@ class TargetTransformInfo {
233233
/// the EXT operation.
234234
int getExtCost(const Instruction *I, const Value *Src) const;
235235

236-
/// Estimate the cost of a function call when lowered.
237-
///
238-
/// The contract for this is the same as \c getOperationCost except that it
239-
/// supports an interface that provides extra information specific to call
240-
/// instructions.
241-
///
242-
/// This is the most basic query for estimating call cost: it only knows the
243-
/// function type and (potentially) the number of arguments at the call site.
244-
/// The latter is only interesting for varargs function types.
245-
int getCallCost(FunctionType *FTy, int NumArgs = -1,
246-
const User *U = nullptr) const;
247-
248-
/// Estimate the cost of calling a specific function when lowered.
249-
///
250-
/// This overload adds the ability to reason about the particular function
251-
/// being called in the event it is a library call with special lowering.
252-
int getCallCost(const Function *F, int NumArgs = -1,
253-
const User *U = nullptr) const;
254-
255-
/// Estimate the cost of calling a specific function when lowered.
256-
///
257-
/// This overload allows specifying a set of candidate argument values.
258-
int getCallCost(const Function *F, ArrayRef<const Value *> Arguments,
259-
const User *U = nullptr) const;
260-
261236
/// \returns A value by which our inlining threshold should be multiplied.
262237
/// This is primarily used to bump up the inlining threshold wholesale on
263238
/// targets where calls are unusually expensive.
@@ -279,15 +254,11 @@ class TargetTransformInfo {
279254
int getInlinerVectorBonusPercent() const;
280255

281256
/// Estimate the cost of an intrinsic when lowered.
282-
///
283-
/// Mirrors the \c getCallCost method but uses an intrinsic identifier.
284257
int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
285258
ArrayRef<Type *> ParamTys,
286259
const User *U = nullptr) const;
287260

288261
/// Estimate the cost of an intrinsic when lowered.
289-
///
290-
/// Mirrors the \c getCallCost method but uses an intrinsic identifier.
291262
int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
292263
ArrayRef<const Value *> Arguments,
293264
const User *U = nullptr) const;
@@ -1206,10 +1177,6 @@ class TargetTransformInfo::Concept {
12061177
virtual int getGEPCost(Type *PointeeType, const Value *Ptr,
12071178
ArrayRef<const Value *> Operands) = 0;
12081179
virtual int getExtCost(const Instruction *I, const Value *Src) = 0;
1209-
virtual int getCallCost(FunctionType *FTy, int NumArgs, const User *U) = 0;
1210-
virtual int getCallCost(const Function *F, int NumArgs, const User *U) = 0;
1211-
virtual int getCallCost(const Function *F,
1212-
ArrayRef<const Value *> Arguments, const User *U) = 0;
12131180
virtual unsigned getInliningThresholdMultiplier() = 0;
12141181
virtual int getInlinerVectorBonusPercent() = 0;
12151182
virtual int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
@@ -1455,16 +1422,6 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
14551422
int getExtCost(const Instruction *I, const Value *Src) override {
14561423
return Impl.getExtCost(I, Src);
14571424
}
1458-
int getCallCost(FunctionType *FTy, int NumArgs, const User *U) override {
1459-
return Impl.getCallCost(FTy, NumArgs, U);
1460-
}
1461-
int getCallCost(const Function *F, int NumArgs, const User *U) override {
1462-
return Impl.getCallCost(F, NumArgs, U);
1463-
}
1464-
int getCallCost(const Function *F,
1465-
ArrayRef<const Value *> Arguments, const User *U) override {
1466-
return Impl.getCallCost(F, Arguments, U);
1467-
}
14681425
unsigned getInliningThresholdMultiplier() override {
14691426
return Impl.getInliningThresholdMultiplier();
14701427
}

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,6 @@ class TargetTransformInfoImplBase {
132132
return TTI::TCC_Basic;
133133
}
134134

135-
unsigned getCallCost(FunctionType *FTy, int NumArgs, const User *U) {
136-
assert(FTy && "FunctionType must be provided to this routine.");
137-
138-
// The target-independent implementation just measures the size of the
139-
// function by approximating that each argument will take on average one
140-
// instruction to prepare.
141-
142-
if (NumArgs < 0)
143-
// Set the argument number to the number of explicit arguments in the
144-
// function.
145-
NumArgs = FTy->getNumParams();
146-
147-
return TTI::TCC_Basic * (NumArgs + 1);
148-
}
149-
150135
unsigned getInliningThresholdMultiplier() { return 1; }
151136

152137
int getInlinerVectorBonusPercent() { return 150; }
@@ -726,37 +711,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
726711
explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
727712

728713
public:
729-
using BaseT::getCallCost;
730-
731-
unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
732-
assert(F && "A concrete function must be provided to this routine.");
733-
734-
if (NumArgs < 0)
735-
// Set the argument number to the number of explicit arguments in the
736-
// function.
737-
NumArgs = F->arg_size();
738-
739-
if (Intrinsic::ID IID = F->getIntrinsicID()) {
740-
FunctionType *FTy = F->getFunctionType();
741-
SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
742-
return static_cast<T *>(this)
743-
->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
744-
}
745-
746-
if (!static_cast<T *>(this)->isLoweredToCall(F))
747-
return TTI::TCC_Basic; // Give a basic cost if it will be lowered
748-
// directly.
749-
750-
return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
751-
}
752-
753-
unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments,
754-
const User *U) {
755-
// Simply delegate to generic handling of the call.
756-
// FIXME: We should use instsimplify or something else to catch calls which
757-
// will constant fold with these arguments.
758-
return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
759-
}
760714

761715
using BaseT::getGEPCost;
762716

@@ -898,15 +852,19 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
898852

899853
if (auto CS = ImmutableCallSite(U)) {
900854
const Function *F = CS.getCalledFunction();
901-
if (!F) {
902-
// Just use the called value type.
903-
Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
904-
return TargetTTI->getCallCost(cast<FunctionType>(FTy),
905-
CS.arg_size(), U);
906-
}
855+
if (F) {
856+
FunctionType *FTy = F->getFunctionType();
857+
if (Intrinsic::ID IID = F->getIntrinsicID()) {
858+
SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
859+
return TargetTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
860+
}
907861

908-
SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
909-
return TargetTTI->getCallCost(F, Arguments, U);
862+
if (!TargetTTI->isLoweredToCall(F))
863+
return TTI::TCC_Basic; // Give a basic cost if it will be lowered
864+
865+
return TTI::TCC_Basic * (FTy->getNumParams() + 1);
866+
}
867+
return TTI::TCC_Basic * (CS.arg_size() + 1);
910868
}
911869

912870
if (isa<SExtInst>(U) || isa<ZExtInst>(U) || isa<FPExtInst>(U))

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,6 @@ int TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
153153
return Cost;
154154
}
155155

156-
int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs,
157-
const User *U) const {
158-
int Cost = TTIImpl->getCallCost(FTy, NumArgs, U);
159-
assert(Cost >= 0 && "TTI should not produce negative costs!");
160-
return Cost;
161-
}
162-
163-
int TargetTransformInfo::getCallCost(const Function *F,
164-
ArrayRef<const Value *> Arguments,
165-
const User *U) const {
166-
int Cost = TTIImpl->getCallCost(F, Arguments, U);
167-
assert(Cost >= 0 && "TTI should not produce negative costs!");
168-
return Cost;
169-
}
170-
171156
unsigned TargetTransformInfo::getInliningThresholdMultiplier() const {
172157
return TTIImpl->getInliningThresholdMultiplier();
173158
}

0 commit comments

Comments
 (0)