Skip to content

Commit 3334c35

Browse files
authored
[TTI] Fix discrepancies in prototypes between interface and implementations (NFCI) (#136655)
These are not diagnosed because implementations hide the methods of the base class rather than overriding them. This works as long as a hiding function is callable with the same arguments as the same function from the base class. Pull Request: #136655
1 parent ef72b93 commit 3334c35

26 files changed

+84
-91
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,10 +3101,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
31013101
return Impl.areTypesABICompatible(Caller, Callee, Types);
31023102
}
31033103
bool isIndexedLoadLegal(MemIndexedMode Mode, Type *Ty) const override {
3104-
return Impl.isIndexedLoadLegal(Mode, Ty, getDataLayout());
3104+
return Impl.isIndexedLoadLegal(Mode, Ty);
31053105
}
31063106
bool isIndexedStoreLegal(MemIndexedMode Mode, Type *Ty) const override {
3107-
return Impl.isIndexedStoreLegal(Mode, Ty, getDataLayout());
3107+
return Impl.isIndexedStoreLegal(Mode, Ty);
31083108
}
31093109
unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const override {
31103110
return Impl.getLoadStoreVecRegBitWidth(AddrSpace);

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ class TargetTransformInfoImplBase {
471471

472472
bool haveFastSqrt(Type *Ty) const { return false; }
473473

474-
bool isExpensiveToSpeculativelyExecute(const Instruction *I) { return true; }
474+
bool isExpensiveToSpeculativelyExecute(const Instruction *I) const {
475+
return true;
476+
}
475477

476478
bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const { return true; }
477479

@@ -745,9 +747,10 @@ class TargetTransformInfoImplBase {
745747
return 1;
746748
}
747749

748-
unsigned getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF,
749-
const APInt &DemandedDstElts,
750-
TTI::TargetCostKind CostKind) const {
750+
InstructionCost
751+
getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF,
752+
const APInt &DemandedDstElts,
753+
TTI::TargetCostKind CostKind) const {
751754
return 1;
752755
}
753756

@@ -805,7 +808,7 @@ class TargetTransformInfoImplBase {
805808
return InstructionCost::getInvalid();
806809
}
807810

808-
unsigned getInterleavedMemoryOpCost(
811+
InstructionCost getInterleavedMemoryOpCost(
809812
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
810813
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
811814
bool UseMaskForCond, bool UseMaskForGaps) const {
@@ -965,13 +968,11 @@ class TargetTransformInfoImplBase {
965968
Callee->getFnAttribute("target-features"));
966969
}
967970

968-
bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty,
969-
const DataLayout &DL) const {
971+
bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty) const {
970972
return false;
971973
}
972974

973-
bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty,
974-
const DataLayout &DL) const {
975+
bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty) const {
975976
return false;
976977
}
977978

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,19 +475,17 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
475475
return VF;
476476
}
477477

478-
bool isIndexedLoadLegal(TTI::MemIndexedMode M, Type *Ty,
479-
const DataLayout &DL) const {
478+
bool isIndexedLoadLegal(TTI::MemIndexedMode M, Type *Ty) const {
480479
EVT VT = getTLI()->getValueType(DL, Ty);
481480
return getTLI()->isIndexedLoadLegal(getISDIndexedMode(M), VT);
482481
}
483482

484-
bool isIndexedStoreLegal(TTI::MemIndexedMode M, Type *Ty,
485-
const DataLayout &DL) const {
483+
bool isIndexedStoreLegal(TTI::MemIndexedMode M, Type *Ty) const {
486484
EVT VT = getTLI()->getValueType(DL, Ty);
487485
return getTLI()->isIndexedStoreLegal(getISDIndexedMode(M), VT);
488486
}
489487

490-
bool isLSRCostLess(TTI::LSRCost C1, TTI::LSRCost C2) const {
488+
bool isLSRCostLess(const TTI::LSRCost &C1, const TTI::LSRCost &C2) const {
491489
return TargetTransformInfoImplBase::isLSRCostLess(C1, C2);
492490
}
493491

@@ -1468,7 +1466,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
14681466
}
14691467

14701468
InstructionCost getMemoryOpCost(
1471-
unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace,
1469+
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
14721470
TTI::TargetCostKind CostKind,
14731471
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
14741472
const Instruction *I = nullptr) const {

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4367,7 +4367,7 @@ bool AArch64TTIImpl::useNeonVector(const Type *Ty) const {
43674367
}
43684368

43694369
InstructionCost AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
4370-
MaybeAlign Alignment,
4370+
Align Alignment,
43714371
unsigned AddressSpace,
43724372
TTI::TargetCostKind CostKind,
43734373
TTI::OperandValueInfo OpInfo,
@@ -4402,7 +4402,7 @@ InstructionCost AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
44024402
return 1;
44034403

44044404
if (ST->isMisaligned128StoreSlow() && Opcode == Instruction::Store &&
4405-
LT.second.is128BitVector() && (!Alignment || *Alignment < Align(16))) {
4405+
LT.second.is128BitVector() && Alignment < Align(16)) {
44064406
// Unaligned stores are extremely inefficient. We don't split all
44074407
// unaligned 128-bit stores because the negative impact that has shown in
44084408
// practice on inlined block copy code.
@@ -4429,8 +4429,7 @@ InstructionCost AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
44294429
EVT EltVT = VT.getVectorElementType();
44304430
unsigned EltSize = EltVT.getScalarSizeInBits();
44314431
if (!isPowerOf2_32(EltSize) || EltSize < 8 || EltSize > 64 ||
4432-
VT.getVectorNumElements() >= (128 / EltSize) || !Alignment ||
4433-
*Alignment != Align(1))
4432+
VT.getVectorNumElements() >= (128 / EltSize) || Alignment != Align(1))
44344433
return LT.first;
44354434
// FIXME: v3i8 lowering currently is very inefficient, due to automatic
44364435
// widening to v4i8, which produces suboptimal results.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
249249
bool useNeonVector(const Type *Ty) const;
250250

251251
InstructionCost getMemoryOpCost(
252-
unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace,
252+
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
253253
TTI::TargetCostKind CostKind,
254254
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
255255
const Instruction *I = nullptr) const;

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void AMDGPUTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
274274
BaseT::getPeelingPreferences(L, SE, PP);
275275
}
276276

277-
int64_t AMDGPUTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
277+
uint64_t AMDGPUTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
278278
return 1024;
279279
}
280280

@@ -412,7 +412,7 @@ bool GCNTTIImpl::isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes,
412412
return isLegalToVectorizeMemChain(ChainSizeInBytes, Alignment, AddrSpace);
413413
}
414414

415-
int64_t GCNTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
415+
uint64_t GCNTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
416416
return 1024;
417417
}
418418

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AMDGPUTTIImpl final : public BasicTTIImplBase<AMDGPUTTIImpl> {
5757
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
5858
TTI::PeelingPreferences &PP) const;
5959

60-
int64_t getMaxMemIntrinsicInlineSizeThreshold() const;
60+
uint64_t getMaxMemIntrinsicInlineSizeThreshold() const;
6161
};
6262

6363
class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
@@ -137,7 +137,7 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
137137
bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes, Align Alignment,
138138
unsigned AddrSpace) const;
139139

140-
int64_t getMaxMemIntrinsicInlineSizeThreshold() const;
140+
uint64_t getMaxMemIntrinsicInlineSizeThreshold() const;
141141
Type *
142142
getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length,
143143
unsigned SrcAddrSpace, unsigned DestAddrSpace,

llvm/lib/Target/AMDGPU/R600TargetTransformInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ unsigned R600TTIImpl::getHardwareNumberOfRegisters(bool Vec) const {
3232
return 4 * 128; // XXX - 4 channels. Should these count as vector instead?
3333
}
3434

35-
unsigned R600TTIImpl::getNumberOfRegisters(bool Vec) const {
35+
unsigned R600TTIImpl::getNumberOfRegisters(unsigned ClassID) const {
36+
bool Vec = ClassID == 1;
3637
return getHardwareNumberOfRegisters(Vec);
3738
}
3839

llvm/lib/Target/AMDGPU/R600TargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class R600TTIImpl final : public BasicTTIImplBase<R600TTIImpl> {
4747
void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
4848
TTI::PeelingPreferences &PP) const;
4949
unsigned getHardwareNumberOfRegisters(bool Vec) const;
50-
unsigned getNumberOfRegisters(bool Vec) const;
50+
unsigned getNumberOfRegisters(unsigned ClassID) const;
5151
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind Vector) const;
5252
unsigned getMinVectorRegisterBitWidth() const;
5353
unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const;

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ InstructionCost ARMTTIImpl::getArithmeticInstrCost(
15451545
}
15461546

15471547
InstructionCost ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
1548-
MaybeAlign Alignment,
1548+
Align Alignment,
15491549
unsigned AddressSpace,
15501550
TTI::TargetCostKind CostKind,
15511551
TTI::OperandValueInfo OpInfo,
@@ -1559,8 +1559,7 @@ InstructionCost ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
15591559
return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
15601560
CostKind);
15611561

1562-
if (ST->hasNEON() && Src->isVectorTy() &&
1563-
(Alignment && *Alignment != Align(16)) &&
1562+
if (ST->hasNEON() && Src->isVectorTy() && Alignment != Align(16) &&
15641563
cast<VectorType>(Src)->getElementType()->isDoubleTy()) {
15651564
// Unaligned loads/stores are extremely inefficient.
15661565
// We need 4 uops for vst.1/vld.1 vs 1uop for vldr/vstr.

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
263263
const Instruction *CxtI = nullptr) const;
264264

265265
InstructionCost getMemoryOpCost(
266-
unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace,
266+
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
267267
TTI::TargetCostKind CostKind,
268268
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
269269
const Instruction *I = nullptr) const;

llvm/lib/Target/BPF/BPFTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class BPFTTIImpl : public BasicTTIImplBase<BPFTTIImpl> {
3737
: BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
3838
TLI(ST->getTargetLowering()) {}
3939

40-
int getIntImmCost(const APInt &Imm, Type *Ty,
41-
TTI::TargetCostKind CostKind) const {
40+
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
41+
TTI::TargetCostKind CostKind) const {
4242
if (Imm.getBitWidth() <= 64 && isInt<32>(Imm.getSExtValue()))
4343
return TTI::TCC_Free;
4444

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ HexagonTTIImpl::getPreferredAddressingMode(const Loop *L,
104104

105105
/// --- Vector TTI begin ---
106106

107-
unsigned HexagonTTIImpl::getNumberOfRegisters(bool Vector) const {
107+
unsigned HexagonTTIImpl::getNumberOfRegisters(unsigned ClassID) const {
108+
bool Vector = ClassID == 1;
108109
if (Vector)
109110
return useHVX() ? 32 : 0;
110111
return 32;
@@ -162,7 +163,7 @@ InstructionCost HexagonTTIImpl::getAddressComputationCost(Type *Tp,
162163
}
163164

164165
InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
165-
MaybeAlign Alignment,
166+
Align Alignment,
166167
unsigned AddressSpace,
167168
TTI::TargetCostKind CostKind,
168169
TTI::OperandValueInfo OpInfo,
@@ -189,10 +190,9 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
189190
return VecWidth / RegWidth;
190191
// Cost of constructing HVX vector from scalar loads
191192
const Align RegAlign(RegWidth / 8);
192-
if (!Alignment || *Alignment > RegAlign)
193+
if (Alignment > RegAlign)
193194
Alignment = RegAlign;
194-
assert(Alignment);
195-
unsigned AlignWidth = 8 * Alignment->value();
195+
unsigned AlignWidth = 8 * Alignment.value();
196196
unsigned NumLoads = alignTo(VecWidth, AlignWidth) / AlignWidth;
197197
return 3 * NumLoads;
198198
}
@@ -203,7 +203,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
203203
VecTy->getElementType()->isFloatingPointTy() ? FloatFactor : 1;
204204

205205
// At this point unspecified alignment is considered as Align(1).
206-
const Align BoundAlignment = std::min(Alignment.valueOrOne(), Align(8));
206+
const Align BoundAlignment = std::min(Alignment, Align(8));
207207
unsigned AlignWidth = 8 * BoundAlignment.value();
208208
unsigned NumLoads = alignTo(VecWidth, AlignWidth) / AlignWidth;
209209
if (Alignment == Align(4) || Alignment == Align(8))
@@ -226,12 +226,10 @@ HexagonTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
226226
CostKind);
227227
}
228228

229-
InstructionCost HexagonTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
230-
ArrayRef<int> Mask,
231-
TTI::TargetCostKind CostKind,
232-
int Index, Type *SubTp,
233-
ArrayRef<const Value *> Args,
234-
const Instruction *CxtI) const {
229+
InstructionCost HexagonTTIImpl::getShuffleCost(
230+
TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef<int> Mask,
231+
TTI::TargetCostKind CostKind, int Index, VectorType *SubTp,
232+
ArrayRef<const Value *> Args, const Instruction *CxtI) const {
235233
return 1;
236234
}
237235

@@ -251,8 +249,7 @@ InstructionCost HexagonTTIImpl::getInterleavedMemoryOpCost(
251249
Alignment, AddressSpace,
252250
CostKind,
253251
UseMaskForCond, UseMaskForGaps);
254-
return getMemoryOpCost(Opcode, VecTy, MaybeAlign(Alignment), AddressSpace,
255-
CostKind);
252+
return getMemoryOpCost(Opcode, VecTy, Alignment, AddressSpace, CostKind);
256253
}
257254

258255
InstructionCost HexagonTTIImpl::getCmpSelInstrCost(

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
8181
/// \name Vector TTI Implementations
8282
/// @{
8383

84-
unsigned getNumberOfRegisters(bool vector) const;
84+
unsigned getNumberOfRegisters(unsigned ClassID) const;
8585
unsigned getMaxInterleaveFactor(ElementCount VF) const;
8686
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const;
8787
unsigned getMinVectorRegisterBitWidth() const;
@@ -107,17 +107,18 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
107107
InstructionCost getAddressComputationCost(Type *Tp, ScalarEvolution *SE,
108108
const SCEV *S) const;
109109
InstructionCost getMemoryOpCost(
110-
unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace,
110+
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
111111
TTI::TargetCostKind CostKind,
112112
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
113113
const Instruction *I = nullptr) const;
114114
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
115115
Align Alignment, unsigned AddressSpace,
116116
TTI::TargetCostKind CostKind) const;
117-
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
117+
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
118118
ArrayRef<int> Mask,
119119
TTI::TargetCostKind CostKind, int Index,
120-
Type *SubTp, ArrayRef<const Value *> Args = {},
120+
VectorType *SubTp,
121+
ArrayRef<const Value *> Args = {},
121122
const Instruction *CxtI = nullptr) const;
122123
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
123124
const Value *Ptr, bool VariableMask,

llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class NVPTXTTIImpl : public BasicTTIImplBase<NVPTXTTIImpl> {
7474
// vectorizers but disables heuristics based on the number of registers.
7575
// FIXME: Return a more reasonable number, while keeping an eye on
7676
// LoopVectorizer's unrolling heuristics.
77-
unsigned getNumberOfRegisters(bool Vector) const { return 1; }
77+
unsigned getNumberOfRegisters(unsigned ClassID) const { return 1; }
7878

7979
// Only <2 x half> should be vectorized, so always return 32 for the vector
8080
// register size.

0 commit comments

Comments
 (0)