Skip to content

Commit 01bc742

Browse files
authored
[CodeGen] Give ArgListEntry a proper constructor (NFC) (#153817)
This ensures that the required fields are set, and also makes the construction more convenient.
1 parent 1d1e52e commit 01bc742

27 files changed

+148
-364
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ class LLVM_ABI TargetLoweringBase {
299299

300300
class ArgListEntry {
301301
public:
302-
Value *Val = nullptr;
303-
SDValue Node = SDValue();
304-
Type *Ty = nullptr;
302+
Value *Val;
303+
SDValue Node;
304+
Type *Ty;
305305
bool IsSExt : 1;
306306
bool IsZExt : 1;
307307
bool IsNoExt : 1;
@@ -320,12 +320,17 @@ class LLVM_ABI TargetLoweringBase {
320320
MaybeAlign Alignment = std::nullopt;
321321
Type *IndirectType = nullptr;
322322

323-
ArgListEntry()
324-
: IsSExt(false), IsZExt(false), IsNoExt(false), IsInReg(false),
325-
IsSRet(false), IsNest(false), IsByVal(false), IsByRef(false),
326-
IsInAlloca(false), IsPreallocated(false), IsReturned(false),
327-
IsSwiftSelf(false), IsSwiftAsync(false), IsSwiftError(false),
328-
IsCFGuardTarget(false) {}
323+
ArgListEntry(Value *Val, SDValue Node, Type *Ty)
324+
: Val(Val), Node(Node), Ty(Ty), IsSExt(false), IsZExt(false),
325+
IsNoExt(false), IsInReg(false), IsSRet(false), IsNest(false),
326+
IsByVal(false), IsByRef(false), IsInAlloca(false),
327+
IsPreallocated(false), IsReturned(false), IsSwiftSelf(false),
328+
IsSwiftAsync(false), IsSwiftError(false), IsCFGuardTarget(false) {}
329+
330+
explicit ArgListEntry(Value *Val, SDValue Node = SDValue())
331+
: ArgListEntry(Val, Node, Val->getType()) {}
332+
333+
ArgListEntry(SDValue Node, Type *Ty) : ArgListEntry(nullptr, Node, Ty) {}
329334

330335
LLVM_ABI void setAttributes(const CallBase *Call, unsigned ArgIdx);
331336
};

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,7 @@ bool FastISel::lowerCallOperands(const CallInst *CI, unsigned ArgIdx,
729729

730730
assert(!V->getType()->isEmptyTy() && "Empty type passed to intrinsic.");
731731

732-
ArgListEntry Entry;
733-
Entry.Val = V;
734-
Entry.Ty = V->getType();
732+
ArgListEntry Entry(V);
735733
Entry.setAttributes(CI, ArgI);
736734
Args.push_back(Entry);
737735
}
@@ -978,9 +976,7 @@ bool FastISel::lowerCallTo(const CallInst *CI, MCSymbol *Symbol,
978976

979977
assert(!V->getType()->isEmptyTy() && "Empty type passed to intrinsic.");
980978

981-
ArgListEntry Entry;
982-
Entry.Val = V;
983-
Entry.Ty = V->getType();
979+
ArgListEntry Entry(V);
984980
Entry.setAttributes(CI, ArgI);
985981
Args.push_back(Entry);
986982
}
@@ -1116,7 +1112,6 @@ bool FastISel::lowerCall(const CallInst *CI) {
11161112
Type *RetTy = CI->getType();
11171113

11181114
ArgListTy Args;
1119-
ArgListEntry Entry;
11201115
Args.reserve(CI->arg_size());
11211116

11221117
for (auto i = CI->arg_begin(), e = CI->arg_end(); i != e; ++i) {
@@ -1126,9 +1121,7 @@ bool FastISel::lowerCall(const CallInst *CI) {
11261121
if (V->getType()->isEmptyTy())
11271122
continue;
11281123

1129-
Entry.Val = V;
1130-
Entry.Ty = V->getType();
1131-
1124+
ArgListEntry Entry(V);
11321125
// Skip the first return-type Attribute to get to params.
11331126
Entry.setAttributes(CI, i - CI->arg_begin());
11341127
Args.push_back(Entry);

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,12 +2181,10 @@ SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
21812181
std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
21822182
bool isSigned) {
21832183
TargetLowering::ArgListTy Args;
2184-
TargetLowering::ArgListEntry Entry;
21852184
for (const SDValue &Op : Node->op_values()) {
21862185
EVT ArgVT = Op.getValueType();
21872186
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
2188-
Entry.Node = Op;
2189-
Entry.Ty = ArgTy;
2187+
TargetLowering::ArgListEntry Entry(Op, ArgTy);
21902188
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, isSigned);
21912189
Entry.IsZExt = !Entry.IsSExt;
21922190
Args.push_back(Entry);
@@ -2325,11 +2323,9 @@ SDValue SelectionDAGLegalize::ExpandBitCountingLibCall(
23252323
EVT IntVT =
23262324
EVT::getIntegerVT(*DAG.getContext(), DAG.getLibInfo().getIntSize());
23272325

2328-
TargetLowering::ArgListEntry Arg;
23292326
EVT ArgVT = Op.getValueType();
23302327
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
2331-
Arg.Node = Op;
2332-
Arg.Ty = ArgTy;
2328+
TargetLowering::ArgListEntry Arg(Op, ArgTy);
23332329
Arg.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, /*IsSigned=*/false);
23342330
Arg.IsZExt = !Arg.IsSExt;
23352331

@@ -2370,21 +2366,19 @@ SelectionDAGLegalize::ExpandDivRemLibCall(SDNode *Node,
23702366
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
23712367

23722368
TargetLowering::ArgListTy Args;
2373-
TargetLowering::ArgListEntry Entry;
23742369
for (const SDValue &Op : Node->op_values()) {
23752370
EVT ArgVT = Op.getValueType();
23762371
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
2377-
Entry.Node = Op;
2378-
Entry.Ty = ArgTy;
2372+
TargetLowering::ArgListEntry Entry(Op, ArgTy);
23792373
Entry.IsSExt = isSigned;
23802374
Entry.IsZExt = !isSigned;
23812375
Args.push_back(Entry);
23822376
}
23832377

23842378
// Also pass the return address of the remainder.
23852379
SDValue FIPtr = DAG.CreateStackTemporary(RetVT);
2386-
Entry.Node = FIPtr;
2387-
Entry.Ty = PointerType::getUnqual(RetTy->getContext());
2380+
TargetLowering::ArgListEntry Entry(
2381+
FIPtr, PointerType::getUnqual(RetTy->getContext()));
23882382
Entry.IsSExt = isSigned;
23892383
Entry.IsZExt = !isSigned;
23902384
Args.push_back(Entry);

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5260,20 +5260,18 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N,
52605260
MachinePointerInfo());
52615261

52625262
TargetLowering::ArgListTy Args;
5263-
TargetLowering::ArgListEntry Entry;
52645263
for (const SDValue &Op : N->op_values()) {
52655264
EVT ArgVT = Op.getValueType();
52665265
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
5267-
Entry.Node = Op;
5268-
Entry.Ty = ArgTy;
5266+
TargetLowering::ArgListEntry Entry(Op, ArgTy);
52695267
Entry.IsSExt = true;
52705268
Entry.IsZExt = false;
52715269
Args.push_back(Entry);
52725270
}
52735271

52745272
// Also pass the address of the overflow check.
5275-
Entry.Node = Temp;
5276-
Entry.Ty = PointerType::getUnqual(PtrTy->getContext());
5273+
TargetLowering::ArgListEntry Entry(
5274+
Temp, PointerType::getUnqual(PtrTy->getContext()));
52775275
Entry.IsSExt = true;
52785276
Entry.IsZExt = false;
52795277
Args.push_back(Entry);

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,27 +2223,21 @@ bool VectorLegalizer::tryExpandVecMathCall(SDNode *Node, RTLIB::Libcall LC,
22232223

22242224
SDLoc DL(Node);
22252225
TargetLowering::ArgListTy Args;
2226-
TargetLowering::ArgListEntry Entry;
2227-
Entry.IsSExt = false;
2228-
Entry.IsZExt = false;
22292226

22302227
unsigned OpNum = 0;
22312228
for (auto &VFParam : OptVFInfo->Shape.Parameters) {
22322229
if (VFParam.ParamKind == VFParamKind::GlobalPredicate) {
22332230
EVT MaskVT = TLI.getSetCCResultType(DAG.getDataLayout(), *Ctx, VT);
2234-
Entry.Node = DAG.getBoolConstant(true, DL, MaskVT, VT);
2235-
Entry.Ty = MaskVT.getTypeForEVT(*Ctx);
2236-
Args.push_back(Entry);
2231+
Args.emplace_back(DAG.getBoolConstant(true, DL, MaskVT, VT),
2232+
MaskVT.getTypeForEVT(*Ctx));
22372233
continue;
22382234
}
22392235

22402236
// Only vector operands are supported.
22412237
if (VFParam.ParamKind != VFParamKind::Vector)
22422238
return false;
22432239

2244-
Entry.Node = Node->getOperand(OpNum++);
2245-
Entry.Ty = Ty;
2246-
Args.push_back(Entry);
2240+
Args.emplace_back(Node->getOperand(OpNum++), Ty);
22472241
}
22482242

22492243
// Emit a call to the vector function.

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 31 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,18 +2576,12 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
25762576
}
25772577

25782578
TargetLowering::ArgListTy Args;
2579-
auto AddArgListEntry = [&](SDValue Node, Type *Ty) {
2580-
TargetLowering::ArgListEntry Entry{};
2581-
Entry.Ty = Ty;
2582-
Entry.Node = Node;
2583-
Args.push_back(Entry);
2584-
};
25852579

25862580
// Pass the arguments.
25872581
for (const SDValue &Op : Node->op_values()) {
25882582
EVT ArgVT = Op.getValueType();
25892583
Type *ArgTy = ArgVT.getTypeForEVT(Ctx);
2590-
AddArgListEntry(Op, ArgTy);
2584+
Args.emplace_back(Op, ArgTy);
25912585
}
25922586

25932587
// Pass the output pointers.
@@ -2599,7 +2593,7 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
25992593
EVT ResVT = Node->getValueType(ResNo);
26002594
SDValue ResultPtr = ST ? ST->getBasePtr() : CreateStackTemporary(ResVT);
26012595
ResultPtrs[ResNo] = ResultPtr;
2602-
AddArgListEntry(ResultPtr, PointerTy);
2596+
Args.emplace_back(ResultPtr, PointerTy);
26032597
}
26042598

26052599
SDLoc DL(Node);
@@ -2608,7 +2602,7 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
26082602
if (VD && VD->isMasked()) {
26092603
EVT MaskVT = TLI->getSetCCResultType(getDataLayout(), Ctx, VT);
26102604
SDValue Mask = getBoolConstant(true, DL, MaskVT, VT);
2611-
AddArgListEntry(Mask, MaskVT.getTypeForEVT(Ctx));
2605+
Args.emplace_back(Mask, MaskVT.getTypeForEVT(Ctx));
26122606
}
26132607

26142608
Type *RetType = CallRetResNo.has_value()
@@ -9019,18 +9013,11 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
90199013
if (!LibCallName)
90209014
return {};
90219015

9022-
// Emit a library call.
9023-
auto GetEntry = [](Type *Ty, SDValue &SDV) {
9024-
TargetLowering::ArgListEntry E;
9025-
E.Ty = Ty;
9026-
E.Node = SDV;
9027-
return E;
9028-
};
9029-
90309016
PointerType *PT = PointerType::getUnqual(*getContext());
90319017
TargetLowering::ArgListTy Args = {
9032-
GetEntry(PT, Mem0), GetEntry(PT, Mem1),
9033-
GetEntry(getDataLayout().getIntPtrType(*getContext()), Size)};
9018+
{Mem0, PT},
9019+
{Mem1, PT},
9020+
{Size, getDataLayout().getIntPtrType(*getContext())}};
90349021

90359022
TargetLowering::CallLoweringInfo CLI(*this);
90369023
bool IsTailCall = false;
@@ -9101,13 +9088,10 @@ SDValue SelectionDAG::getMemcpy(
91019088

91029089
// Emit a library call.
91039090
TargetLowering::ArgListTy Args;
9104-
TargetLowering::ArgListEntry Entry;
9105-
Entry.Ty = PointerType::getUnqual(*getContext());
9106-
Entry.Node = Dst; Args.push_back(Entry);
9107-
Entry.Node = Src; Args.push_back(Entry);
9108-
9109-
Entry.Ty = getDataLayout().getIntPtrType(*getContext());
9110-
Entry.Node = Size; Args.push_back(Entry);
9091+
Type *PtrTy = PointerType::getUnqual(*getContext());
9092+
Args.emplace_back(Dst, PtrTy);
9093+
Args.emplace_back(Src, PtrTy);
9094+
Args.emplace_back(Size, getDataLayout().getIntPtrType(*getContext()));
91119095
// FIXME: pass in SDLoc
91129096
TargetLowering::CallLoweringInfo CLI(*this);
91139097
bool IsTailCall = false;
@@ -9145,17 +9129,10 @@ SDValue SelectionDAG::getAtomicMemcpy(SDValue Chain, const SDLoc &dl,
91459129
MachinePointerInfo SrcPtrInfo) {
91469130
// Emit a library call.
91479131
TargetLowering::ArgListTy Args;
9148-
TargetLowering::ArgListEntry Entry;
9149-
Entry.Ty = getDataLayout().getIntPtrType(*getContext());
9150-
Entry.Node = Dst;
9151-
Args.push_back(Entry);
9152-
9153-
Entry.Node = Src;
9154-
Args.push_back(Entry);
9155-
9156-
Entry.Ty = SizeTy;
9157-
Entry.Node = Size;
9158-
Args.push_back(Entry);
9132+
Type *ArgTy = getDataLayout().getIntPtrType(*getContext());
9133+
Args.emplace_back(Dst, ArgTy);
9134+
Args.emplace_back(Src, ArgTy);
9135+
Args.emplace_back(Size, SizeTy);
91599136

91609137
RTLIB::Libcall LibraryCall =
91619138
RTLIB::getMEMCPY_ELEMENT_UNORDERED_ATOMIC(ElemSz);
@@ -9218,13 +9195,10 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
92189195

92199196
// Emit a library call.
92209197
TargetLowering::ArgListTy Args;
9221-
TargetLowering::ArgListEntry Entry;
9222-
Entry.Ty = PointerType::getUnqual(*getContext());
9223-
Entry.Node = Dst; Args.push_back(Entry);
9224-
Entry.Node = Src; Args.push_back(Entry);
9225-
9226-
Entry.Ty = getDataLayout().getIntPtrType(*getContext());
9227-
Entry.Node = Size; Args.push_back(Entry);
9198+
Type *PtrTy = PointerType::getUnqual(*getContext());
9199+
Args.emplace_back(Dst, PtrTy);
9200+
Args.emplace_back(Src, PtrTy);
9201+
Args.emplace_back(Size, getDataLayout().getIntPtrType(*getContext()));
92289202
// FIXME: pass in SDLoc
92299203
TargetLowering::CallLoweringInfo CLI(*this);
92309204

@@ -9262,17 +9236,10 @@ SDValue SelectionDAG::getAtomicMemmove(SDValue Chain, const SDLoc &dl,
92629236
MachinePointerInfo SrcPtrInfo) {
92639237
// Emit a library call.
92649238
TargetLowering::ArgListTy Args;
9265-
TargetLowering::ArgListEntry Entry;
9266-
Entry.Ty = getDataLayout().getIntPtrType(*getContext());
9267-
Entry.Node = Dst;
9268-
Args.push_back(Entry);
9269-
9270-
Entry.Node = Src;
9271-
Args.push_back(Entry);
9272-
9273-
Entry.Ty = SizeTy;
9274-
Entry.Node = Size;
9275-
Args.push_back(Entry);
9239+
Type *IntPtrTy = getDataLayout().getIntPtrType(*getContext());
9240+
Args.emplace_back(Dst, IntPtrTy);
9241+
Args.emplace_back(Src, IntPtrTy);
9242+
Args.emplace_back(Size, SizeTy);
92769243

92779244
RTLIB::Libcall LibraryCall =
92789245
RTLIB::getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(ElemSz);
@@ -9349,28 +9316,20 @@ SDValue SelectionDAG::getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
93499316

93509317
const char *BzeroName = getTargetLoweringInfo().getLibcallName(RTLIB::BZERO);
93519318

9352-
// Helper function to create an Entry from Node and Type.
9353-
const auto CreateEntry = [](SDValue Node, Type *Ty) {
9354-
TargetLowering::ArgListEntry Entry;
9355-
Entry.Node = Node;
9356-
Entry.Ty = Ty;
9357-
return Entry;
9358-
};
9359-
93609319
bool UseBZero = isNullConstant(Src) && BzeroName;
93619320
// If zeroing out and bzero is present, use it.
93629321
if (UseBZero) {
93639322
TargetLowering::ArgListTy Args;
9364-
Args.push_back(CreateEntry(Dst, PointerType::getUnqual(Ctx)));
9365-
Args.push_back(CreateEntry(Size, DL.getIntPtrType(Ctx)));
9323+
Args.emplace_back(Dst, PointerType::getUnqual(Ctx));
9324+
Args.emplace_back(Size, DL.getIntPtrType(Ctx));
93669325
CLI.setLibCallee(
93679326
TLI->getLibcallCallingConv(RTLIB::BZERO), Type::getVoidTy(Ctx),
93689327
getExternalSymbol(BzeroName, TLI->getPointerTy(DL)), std::move(Args));
93699328
} else {
93709329
TargetLowering::ArgListTy Args;
9371-
Args.push_back(CreateEntry(Dst, PointerType::getUnqual(Ctx)));
9372-
Args.push_back(CreateEntry(Src, Src.getValueType().getTypeForEVT(Ctx)));
9373-
Args.push_back(CreateEntry(Size, DL.getIntPtrType(Ctx)));
9330+
Args.emplace_back(Dst, PointerType::getUnqual(Ctx));
9331+
Args.emplace_back(Src, Src.getValueType().getTypeForEVT(Ctx));
9332+
Args.emplace_back(Size, DL.getIntPtrType(Ctx));
93749333
CLI.setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMSET),
93759334
Dst.getValueType().getTypeForEVT(Ctx),
93769335
getExternalSymbol(TLI->getLibcallName(RTLIB::MEMSET),
@@ -9399,18 +9358,9 @@ SDValue SelectionDAG::getAtomicMemset(SDValue Chain, const SDLoc &dl,
93999358
MachinePointerInfo DstPtrInfo) {
94009359
// Emit a library call.
94019360
TargetLowering::ArgListTy Args;
9402-
TargetLowering::ArgListEntry Entry;
9403-
Entry.Ty = getDataLayout().getIntPtrType(*getContext());
9404-
Entry.Node = Dst;
9405-
Args.push_back(Entry);
9406-
9407-
Entry.Ty = Type::getInt8Ty(*getContext());
9408-
Entry.Node = Value;
9409-
Args.push_back(Entry);
9410-
9411-
Entry.Ty = SizeTy;
9412-
Entry.Node = Size;
9413-
Args.push_back(Entry);
9361+
Args.emplace_back(Dst, getDataLayout().getIntPtrType(*getContext()));
9362+
Args.emplace_back(Value, Type::getInt8Ty(*getContext()));
9363+
Args.emplace_back(Size, SizeTy);
94149364

94159365
RTLIB::Libcall LibraryCall =
94169366
RTLIB::getMEMSET_ELEMENT_UNORDERED_ATOMIC(ElemSz);
@@ -14065,10 +14015,7 @@ SDValue SelectionDAG::makeStateFunctionCall(unsigned LibFunc, SDValue Ptr,
1406514015
const SDLoc &DLoc) {
1406614016
assert(InChain.getValueType() == MVT::Other && "Expected token chain");
1406714017
TargetLowering::ArgListTy Args;
14068-
TargetLowering::ArgListEntry Entry;
14069-
Entry.Node = Ptr;
14070-
Entry.Ty = Ptr.getValueType().getTypeForEVT(*getContext());
14071-
Args.push_back(Entry);
14018+
Args.emplace_back(Ptr, Ptr.getValueType().getTypeForEVT(*getContext()));
1407214019
RTLIB::Libcall LC = static_cast<RTLIB::Libcall>(LibFunc);
1407314020
SDValue Callee = getExternalSymbol(TLI->getLibcallName(LC),
1407414021
TLI->getPointerTy(getDataLayout()));

0 commit comments

Comments
 (0)