Skip to content

Commit de25647

Browse files
committed
GlobalISel: Don't use LLT references
These should always be passed by value
1 parent 8c4cf23 commit de25647

File tree

9 files changed

+44
-44
lines changed

9 files changed

+44
-44
lines changed

llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class GISelInstProfileBuilder {
173173
: ID(ID), MRI(MRI) {}
174174
// Profiling methods.
175175
const GISelInstProfileBuilder &addNodeIDOpcode(unsigned Opc) const;
176-
const GISelInstProfileBuilder &addNodeIDRegType(const LLT &Ty) const;
176+
const GISelInstProfileBuilder &addNodeIDRegType(const LLT Ty) const;
177177
const GISelInstProfileBuilder &addNodeIDRegType(const unsigned) const;
178178

179179
const GISelInstProfileBuilder &

llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class LegalizationArtifactCombiner {
8181
// Can't use MIPattern because we don't have a specific constant in mind.
8282
auto *SrcMI = MRI.getVRegDef(SrcReg);
8383
if (SrcMI->getOpcode() == TargetOpcode::G_CONSTANT) {
84-
const LLT &DstTy = MRI.getType(DstReg);
84+
const LLT DstTy = MRI.getType(DstReg);
8585
if (isInstLegal({TargetOpcode::G_CONSTANT, {DstTy}})) {
8686
auto &CstVal = SrcMI->getOperand(1);
8787
Builder.buildConstant(
@@ -125,7 +125,7 @@ class LegalizationArtifactCombiner {
125125
// Can't use MIPattern because we don't have a specific constant in mind.
126126
auto *SrcMI = MRI.getVRegDef(SrcReg);
127127
if (SrcMI->getOpcode() == TargetOpcode::G_CONSTANT) {
128-
const LLT &DstTy = MRI.getType(DstReg);
128+
const LLT DstTy = MRI.getType(DstReg);
129129
if (isInstLegal({TargetOpcode::G_CONSTANT, {DstTy}})) {
130130
auto &CstVal = SrcMI->getOperand(1);
131131
Builder.buildConstant(
@@ -178,7 +178,7 @@ class LegalizationArtifactCombiner {
178178
// Can't use MIPattern because we don't have a specific constant in mind.
179179
auto *SrcMI = MRI.getVRegDef(SrcReg);
180180
if (SrcMI->getOpcode() == TargetOpcode::G_CONSTANT) {
181-
const LLT &DstTy = MRI.getType(DstReg);
181+
const LLT DstTy = MRI.getType(DstReg);
182182
if (isInstLegal({TargetOpcode::G_CONSTANT, {DstTy}})) {
183183
auto &CstVal = SrcMI->getOperand(1);
184184
Builder.buildConstant(

llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct LegalizeActionStep {
153153
LLT NewType;
154154

155155
LegalizeActionStep(LegalizeAction Action, unsigned TypeIdx,
156-
const LLT &NewType)
156+
const LLT NewType)
157157
: Action(Action), TypeIdx(TypeIdx), NewType(NewType) {}
158158

159159
bool operator==(const LegalizeActionStep &RHS) const {
@@ -739,7 +739,7 @@ class LegalizeRuleSet {
739739
}
740740

741741
/// Ensure the scalar or element is at least as wide as Ty.
742-
LegalizeRuleSet &minScalarOrElt(unsigned TypeIdx, const LLT &Ty) {
742+
LegalizeRuleSet &minScalarOrElt(unsigned TypeIdx, const LLT Ty) {
743743
using namespace LegalityPredicates;
744744
using namespace LegalizeMutations;
745745
return actionIf(LegalizeAction::WidenScalar,
@@ -749,7 +749,7 @@ class LegalizeRuleSet {
749749

750750
/// Ensure the scalar or element is at least as wide as Ty.
751751
LegalizeRuleSet &minScalarOrEltIf(LegalityPredicate Predicate,
752-
unsigned TypeIdx, const LLT &Ty) {
752+
unsigned TypeIdx, const LLT Ty) {
753753
using namespace LegalityPredicates;
754754
using namespace LegalizeMutations;
755755
return actionIf(LegalizeAction::WidenScalar,
@@ -759,7 +759,7 @@ class LegalizeRuleSet {
759759
}
760760

761761
/// Ensure the scalar is at least as wide as Ty.
762-
LegalizeRuleSet &minScalar(unsigned TypeIdx, const LLT &Ty) {
762+
LegalizeRuleSet &minScalar(unsigned TypeIdx, const LLT Ty) {
763763
using namespace LegalityPredicates;
764764
using namespace LegalizeMutations;
765765
return actionIf(LegalizeAction::WidenScalar,
@@ -768,7 +768,7 @@ class LegalizeRuleSet {
768768
}
769769

770770
/// Ensure the scalar is at most as wide as Ty.
771-
LegalizeRuleSet &maxScalarOrElt(unsigned TypeIdx, const LLT &Ty) {
771+
LegalizeRuleSet &maxScalarOrElt(unsigned TypeIdx, const LLT Ty) {
772772
using namespace LegalityPredicates;
773773
using namespace LegalizeMutations;
774774
return actionIf(LegalizeAction::NarrowScalar,
@@ -777,7 +777,7 @@ class LegalizeRuleSet {
777777
}
778778

779779
/// Ensure the scalar is at most as wide as Ty.
780-
LegalizeRuleSet &maxScalar(unsigned TypeIdx, const LLT &Ty) {
780+
LegalizeRuleSet &maxScalar(unsigned TypeIdx, const LLT Ty) {
781781
using namespace LegalityPredicates;
782782
using namespace LegalizeMutations;
783783
return actionIf(LegalizeAction::NarrowScalar,
@@ -789,7 +789,7 @@ class LegalizeRuleSet {
789789
/// For example, when the maximum size of one type depends on the size of
790790
/// another such as extracting N bits from an M bit container.
791791
LegalizeRuleSet &maxScalarIf(LegalityPredicate Predicate, unsigned TypeIdx,
792-
const LLT &Ty) {
792+
const LLT Ty) {
793793
using namespace LegalityPredicates;
794794
using namespace LegalizeMutations;
795795
return actionIf(
@@ -801,15 +801,15 @@ class LegalizeRuleSet {
801801
}
802802

803803
/// Limit the range of scalar sizes to MinTy and MaxTy.
804-
LegalizeRuleSet &clampScalar(unsigned TypeIdx, const LLT &MinTy,
805-
const LLT &MaxTy) {
804+
LegalizeRuleSet &clampScalar(unsigned TypeIdx, const LLT MinTy,
805+
const LLT MaxTy) {
806806
assert(MinTy.isScalar() && MaxTy.isScalar() && "Expected scalar types");
807807
return minScalar(TypeIdx, MinTy).maxScalar(TypeIdx, MaxTy);
808808
}
809809

810810
/// Limit the range of scalar sizes to MinTy and MaxTy.
811-
LegalizeRuleSet &clampScalarOrElt(unsigned TypeIdx, const LLT &MinTy,
812-
const LLT &MaxTy) {
811+
LegalizeRuleSet &clampScalarOrElt(unsigned TypeIdx, const LLT MinTy,
812+
const LLT MaxTy) {
813813
return minScalarOrElt(TypeIdx, MinTy).maxScalarOrElt(TypeIdx, MaxTy);
814814
}
815815

@@ -855,7 +855,7 @@ class LegalizeRuleSet {
855855
}
856856

857857
/// Limit the number of elements in EltTy vectors to at least MinElements.
858-
LegalizeRuleSet &clampMinNumElements(unsigned TypeIdx, const LLT &EltTy,
858+
LegalizeRuleSet &clampMinNumElements(unsigned TypeIdx, const LLT EltTy,
859859
unsigned MinElements) {
860860
// Mark the type index as covered:
861861
typeIdx(TypeIdx);
@@ -873,7 +873,7 @@ class LegalizeRuleSet {
873873
});
874874
}
875875
/// Limit the number of elements in EltTy vectors to at most MaxElements.
876-
LegalizeRuleSet &clampMaxNumElements(unsigned TypeIdx, const LLT &EltTy,
876+
LegalizeRuleSet &clampMaxNumElements(unsigned TypeIdx, const LLT EltTy,
877877
unsigned MaxElements) {
878878
// Mark the type index as covered:
879879
typeIdx(TypeIdx);
@@ -896,12 +896,12 @@ class LegalizeRuleSet {
896896
/// No effect if the type is not a vector or does not have the same element
897897
/// type as the constraints.
898898
/// The element type of MinTy and MaxTy must match.
899-
LegalizeRuleSet &clampNumElements(unsigned TypeIdx, const LLT &MinTy,
900-
const LLT &MaxTy) {
899+
LegalizeRuleSet &clampNumElements(unsigned TypeIdx, const LLT MinTy,
900+
const LLT MaxTy) {
901901
assert(MinTy.getElementType() == MaxTy.getElementType() &&
902902
"Expected element types to agree");
903903

904-
const LLT &EltTy = MinTy.getElementType();
904+
const LLT EltTy = MinTy.getElementType();
905905
return clampMinNumElements(TypeIdx, EltTy, MinTy.getNumElements())
906906
.clampMaxNumElements(TypeIdx, EltTy, MaxTy.getNumElements());
907907
}

llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ template <> struct bind_helper<MachineInstr *> {
133133
};
134134

135135
template <> struct bind_helper<LLT> {
136-
static bool bind(const MachineRegisterInfo &MRI, LLT &Ty, Register Reg) {
136+
static bool bind(const MachineRegisterInfo &MRI, LLT Ty, Register Reg) {
137137
Ty = MRI.getType(Reg);
138138
if (Ty.isValid())
139139
return true;
@@ -163,7 +163,7 @@ template <typename Class> struct bind_ty {
163163

164164
inline bind_ty<Register> m_Reg(Register &R) { return R; }
165165
inline bind_ty<MachineInstr *> m_MInstr(MachineInstr *&MI) { return MI; }
166-
inline bind_ty<LLT> m_Type(LLT &Ty) { return Ty; }
166+
inline bind_ty<LLT> m_Type(LLT Ty) { return Ty; }
167167
inline bind_ty<CmpInst::Predicate> m_Pred(CmpInst::Predicate &P) { return P; }
168168
inline operand_type_match m_Pred() { return operand_type_match(); }
169169

@@ -365,7 +365,7 @@ m_GFCmp(const Pred &P, const LHS &L, const RHS &R) {
365365
// Helper for checking if a Reg is of specific type.
366366
struct CheckType {
367367
LLT Ty;
368-
CheckType(const LLT &Ty) : Ty(Ty) {}
368+
CheckType(const LLT Ty) : Ty(Ty) {}
369369

370370
bool match(const MachineRegisterInfo &MRI, Register Reg) {
371371
return MRI.getType(Reg) == Ty;

llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DstOp {
6868
DstOp(unsigned R) : Reg(R), Ty(DstType::Ty_Reg) {}
6969
DstOp(Register R) : Reg(R), Ty(DstType::Ty_Reg) {}
7070
DstOp(const MachineOperand &Op) : Reg(Op.getReg()), Ty(DstType::Ty_Reg) {}
71-
DstOp(const LLT &T) : LLTTy(T), Ty(DstType::Ty_LLT) {}
71+
DstOp(const LLT T) : LLTTy(T), Ty(DstType::Ty_LLT) {}
7272
DstOp(const TargetRegisterClass *TRC) : RC(TRC), Ty(DstType::Ty_RC) {}
7373

7474
void addDefToMIB(MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) const {
@@ -223,13 +223,13 @@ class MachineIRBuilder {
223223
MachineIRBuilderState State;
224224

225225
protected:
226-
void validateTruncExt(const LLT &Dst, const LLT &Src, bool IsExtend);
226+
void validateTruncExt(const LLT Dst, const LLT Src, bool IsExtend);
227227

228-
void validateBinaryOp(const LLT &Res, const LLT &Op0, const LLT &Op1);
229-
void validateShiftOp(const LLT &Res, const LLT &Op0, const LLT &Op1);
228+
void validateBinaryOp(const LLT Res, const LLT Op0, const LLT Op1);
229+
void validateShiftOp(const LLT Res, const LLT Op0, const LLT Op1);
230230

231-
void validateSelectOp(const LLT &ResTy, const LLT &TstTy, const LLT &Op0Ty,
232-
const LLT &Op1Ty);
231+
void validateSelectOp(const LLT ResTy, const LLT TstTy, const LLT Op0Ty,
232+
const LLT Op1Ty);
233233
void recordInsertion(MachineInstr *MI) const;
234234

235235
public:
@@ -436,7 +436,7 @@ class MachineIRBuilder {
436436
///
437437
/// \return a MachineInstrBuilder for the newly created instruction.
438438
Optional<MachineInstrBuilder> materializePtrAdd(Register &Res, Register Op0,
439-
const LLT &ValueTy,
439+
const LLT ValueTy,
440440
uint64_t Value);
441441

442442
/// Build and insert \p Res = G_PTR_MASK \p Op0, \p NumBits

llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ GISelInstProfileBuilder::addNodeIDOpcode(unsigned Opc) const {
287287
}
288288

289289
const GISelInstProfileBuilder &
290-
GISelInstProfileBuilder::addNodeIDRegType(const LLT &Ty) const {
290+
GISelInstProfileBuilder::addNodeIDRegType(const LLT Ty) const {
291291
uint64_t Val = Ty.getUniqueRAWLLTData();
292292
ID.AddInteger(Val);
293293
return *this;

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ namespace {
295295
/// Select a preference between two uses. CurrentUse is the current preference
296296
/// while *ForCandidate is attributes of the candidate under consideration.
297297
PreferredTuple ChoosePreferredUse(PreferredTuple &CurrentUse,
298-
const LLT &TyForCandidate,
298+
const LLT TyForCandidate,
299299
unsigned OpcodeForCandidate,
300300
MachineInstr *MIForCandidate) {
301301
if (!CurrentUse.Ty.isValid()) {
@@ -499,7 +499,7 @@ void CombinerHelper::applyCombineExtendingLoads(MachineInstr &MI,
499499
UseMI->getOpcode() == TargetOpcode::G_ANYEXT) {
500500
Register UseDstReg = UseMI->getOperand(0).getReg();
501501
MachineOperand &UseSrcMO = UseMI->getOperand(1);
502-
const LLT &UseDstTy = MRI.getType(UseDstReg);
502+
const LLT UseDstTy = MRI.getType(UseDstReg);
503503
if (UseDstReg != ChosenDstReg) {
504504
if (Preferred.Ty == UseDstTy) {
505505
// If the use has the same type as the preferred use, then merge
@@ -1151,7 +1151,7 @@ bool CombinerHelper::optimizeMemcpy(MachineInstr &MI, Register Dst,
11511151
// Construct MMOs for the accesses.
11521152
auto *LoadMMO =
11531153
MF.getMachineMemOperand(&SrcMMO, CurrOffset, CopyTy.getSizeInBytes());
1154-
auto *StoreMMO =
1154+
auto *StoreMMO =
11551155
MF.getMachineMemOperand(&DstMMO, CurrOffset, CopyTy.getSizeInBytes());
11561156

11571157
// Create the load.

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ void IRTranslator::emitSwitchCase(SwitchCG::CaseBlock &CB,
604604
Cond =
605605
MIB.buildICmp(CmpInst::ICMP_SLE, i1Ty, CmpOpReg, CondRHS).getReg(0);
606606
} else {
607-
const LLT &CmpTy = MRI->getType(CmpOpReg);
607+
const LLT CmpTy = MRI->getType(CmpOpReg);
608608
auto Sub = MIB.buildSub({CmpTy}, CmpOpReg, CondLHS);
609609
auto Diff = MIB.buildConstant(CmpTy, High - Low);
610610
Cond = MIB.buildICmp(CmpInst::ICMP_ULE, i1Ty, Sub, Diff).getReg(0);
@@ -1956,7 +1956,7 @@ bool IRTranslator::translateExtractElement(const User &U,
19561956
if (!Idx)
19571957
Idx = getOrCreateVReg(*U.getOperand(1));
19581958
if (MRI->getType(Idx).getSizeInBits() != PreferredVecIdxWidth) {
1959-
const LLT &VecIdxTy = LLT::scalar(PreferredVecIdxWidth);
1959+
const LLT VecIdxTy = LLT::scalar(PreferredVecIdxWidth);
19601960
Idx = MIRBuilder.buildSExtOrTrunc(VecIdxTy, Idx).getReg(0);
19611961
}
19621962
MIRBuilder.buildExtractVectorElement(Res, Val, Idx);

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ MachineInstrBuilder MachineIRBuilder::buildJumpTable(const LLT PtrTy,
199199
.addJumpTableIndex(JTI);
200200
}
201201

202-
void MachineIRBuilder::validateBinaryOp(const LLT &Res, const LLT &Op0,
203-
const LLT &Op1) {
202+
void MachineIRBuilder::validateBinaryOp(const LLT Res, const LLT Op0,
203+
const LLT Op1) {
204204
assert((Res.isScalar() || Res.isVector()) && "invalid operand type");
205205
assert((Res == Op0 && Res == Op1) && "type mismatch");
206206
}
207207

208-
void MachineIRBuilder::validateShiftOp(const LLT &Res, const LLT &Op0,
209-
const LLT &Op1) {
208+
void MachineIRBuilder::validateShiftOp(const LLT Res, const LLT Op0,
209+
const LLT Op1) {
210210
assert((Res.isScalar() || Res.isVector()) && "invalid operand type");
211211
assert((Res == Op0) && "type mismatch");
212212
}
@@ -223,7 +223,7 @@ MachineInstrBuilder MachineIRBuilder::buildPtrAdd(const DstOp &Res,
223223

224224
Optional<MachineInstrBuilder>
225225
MachineIRBuilder::materializePtrAdd(Register &Res, Register Op0,
226-
const LLT &ValueTy, uint64_t Value) {
226+
const LLT ValueTy, uint64_t Value) {
227227
assert(Res == 0 && "Res is a result argument");
228228
assert(ValueTy.isScalar() && "invalid offset type");
229229

@@ -912,7 +912,7 @@ MachineIRBuilder::buildBlockAddress(Register Res, const BlockAddress *BA) {
912912
return buildInstr(TargetOpcode::G_BLOCK_ADDR).addDef(Res).addBlockAddress(BA);
913913
}
914914

915-
void MachineIRBuilder::validateTruncExt(const LLT &DstTy, const LLT &SrcTy,
915+
void MachineIRBuilder::validateTruncExt(const LLT DstTy, const LLT SrcTy,
916916
bool IsExtend) {
917917
#ifndef NDEBUG
918918
if (DstTy.isVector()) {
@@ -931,8 +931,8 @@ void MachineIRBuilder::validateTruncExt(const LLT &DstTy, const LLT &SrcTy,
931931
#endif
932932
}
933933

934-
void MachineIRBuilder::validateSelectOp(const LLT &ResTy, const LLT &TstTy,
935-
const LLT &Op0Ty, const LLT &Op1Ty) {
934+
void MachineIRBuilder::validateSelectOp(const LLT ResTy, const LLT TstTy,
935+
const LLT Op0Ty, const LLT Op1Ty) {
936936
#ifndef NDEBUG
937937
assert((ResTy.isScalar() || ResTy.isVector() || ResTy.isPointer()) &&
938938
"invalid operand type");

0 commit comments

Comments
 (0)