Skip to content

Commit a0c42ca

Browse files
committed
[NFC] Remove AttributeList::hasParamAttribute()
It's the same as AttributeList::hasParamAttr().
1 parent 5eeaac2 commit a0c42ca

File tree

15 files changed

+51
-59
lines changed

15 files changed

+51
-59
lines changed

llvm/include/llvm/IR/Attributes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,6 @@ class AttributeList {
660660
/// may be faster.
661661
bool hasFnAttribute(StringRef Kind) const;
662662

663-
/// Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
664-
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const;
665-
666663
/// Return true if the specified attribute is set for at least one
667664
/// parameter or for the return value. If Index is not nullptr, the index
668665
/// of a parameter with the specified attribute is provided.

llvm/include/llvm/IR/Function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class Function : public GlobalObject, public ilist_node<Function> {
447447

448448
/// check if an attributes is in the list of attributes.
449449
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const {
450-
return getAttributes().hasParamAttribute(ArgNo, Kind);
450+
return getAttributes().hasParamAttr(ArgNo, Kind);
451451
}
452452

453453
/// gets the specified attribute from the list of attributes.
@@ -692,8 +692,8 @@ class Function : public GlobalObject, public ilist_node<Function> {
692692
/// Determine if the function returns a structure through first
693693
/// or second pointer argument.
694694
bool hasStructRetAttr() const {
695-
return AttributeSets.hasParamAttribute(0, Attribute::StructRet) ||
696-
AttributeSets.hasParamAttribute(1, Attribute::StructRet);
695+
return AttributeSets.hasParamAttr(0, Attribute::StructRet) ||
696+
AttributeSets.hasParamAttr(1, Attribute::StructRet);
697697
}
698698

699699
/// Determine if the parameter or return value is marked with NoAlias

llvm/lib/Analysis/Lint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void Lint::visitCallBase(CallBase &I) {
235235
for (auto BI = I.arg_begin(); BI != AE; ++BI, ++ArgNo) {
236236
// Skip ByVal arguments since they will be memcpy'd to the callee's
237237
// stack so we're not really passing the pointer anyway.
238-
if (PAL.hasParamAttribute(ArgNo, Attribute::ByVal))
238+
if (PAL.hasParamAttr(ArgNo, Attribute::ByVal))
239239
continue;
240240
// If both arguments are readonly, they have no dependence.
241241
if (Formal->onlyReadsMemory() && I.onlyReadsMemory(ArgNo))
@@ -268,7 +268,7 @@ void Lint::visitCallBase(CallBase &I) {
268268
for (Value *Arg : I.args()) {
269269
// Skip ByVal arguments since they will be memcpy'd to the callee's
270270
// stack anyway.
271-
if (PAL.hasParamAttribute(ArgNo++, Attribute::ByVal))
271+
if (PAL.hasParamAttr(ArgNo++, Attribute::ByVal))
272272
continue;
273273
Value *Obj = findValue(Arg, /*OffsetOk=*/true);
274274
Assert(!isa<AllocaInst>(Obj),

llvm/lib/IR/Attributes.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,11 +1405,6 @@ bool AttributeList::hasFnAttribute(StringRef Kind) const {
14051405
return hasAttribute(AttributeList::FunctionIndex, Kind);
14061406
}
14071407

1408-
bool AttributeList::hasParamAttribute(unsigned ArgNo,
1409-
Attribute::AttrKind Kind) const {
1410-
return hasAttribute(ArgNo + FirstArgIndex, Kind);
1411-
}
1412-
14131408
bool AttributeList::hasAttrSomewhere(Attribute::AttrKind Attr,
14141409
unsigned *Index) const {
14151410
return pImpl && pImpl->hasAttrSomewhere(Attr, Index);

llvm/lib/IR/Function.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,20 @@ bool Argument::hasPreallocatedAttr() const {
140140
bool Argument::hasPassPointeeByValueCopyAttr() const {
141141
if (!getType()->isPointerTy()) return false;
142142
AttributeList Attrs = getParent()->getAttributes();
143-
return Attrs.hasParamAttribute(getArgNo(), Attribute::ByVal) ||
144-
Attrs.hasParamAttribute(getArgNo(), Attribute::InAlloca) ||
145-
Attrs.hasParamAttribute(getArgNo(), Attribute::Preallocated);
143+
return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
144+
Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
145+
Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated);
146146
}
147147

148148
bool Argument::hasPointeeInMemoryValueAttr() const {
149149
if (!getType()->isPointerTy())
150150
return false;
151151
AttributeList Attrs = getParent()->getAttributes();
152-
return Attrs.hasParamAttribute(getArgNo(), Attribute::ByVal) ||
153-
Attrs.hasParamAttribute(getArgNo(), Attribute::StructRet) ||
154-
Attrs.hasParamAttribute(getArgNo(), Attribute::InAlloca) ||
155-
Attrs.hasParamAttribute(getArgNo(), Attribute::Preallocated) ||
156-
Attrs.hasParamAttribute(getArgNo(), Attribute::ByRef);
152+
return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
153+
Attrs.hasParamAttr(getArgNo(), Attribute::StructRet) ||
154+
Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
155+
Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated) ||
156+
Attrs.hasParamAttr(getArgNo(), Attribute::ByRef);
157157
}
158158

159159
/// For a byval, sret, inalloca, or preallocated parameter, get the in-memory
@@ -278,8 +278,8 @@ bool Argument::hasSExtAttr() const {
278278

279279
bool Argument::onlyReadsMemory() const {
280280
AttributeList Attrs = getParent()->getAttributes();
281-
return Attrs.hasParamAttribute(getArgNo(), Attribute::ReadOnly) ||
282-
Attrs.hasParamAttribute(getArgNo(), Attribute::ReadNone);
281+
return Attrs.hasParamAttr(getArgNo(), Attribute::ReadOnly) ||
282+
Attrs.hasParamAttr(getArgNo(), Attribute::ReadNone);
283283
}
284284

285285
void Argument::addAttrs(AttrBuilder &B) {

llvm/lib/IR/Instructions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ Value *CallBase::getReturnedArgOperand() const {
343343
bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
344344
assert(ArgNo < getNumArgOperands() && "Param index out of bounds!");
345345

346-
if (Attrs.hasParamAttribute(ArgNo, Kind))
346+
if (Attrs.hasParamAttr(ArgNo, Kind))
347347
return true;
348348
if (const Function *F = getCalledFunction())
349-
return F->getAttributes().hasParamAttribute(ArgNo, Kind);
349+
return F->getAttributes().hasParamAttr(ArgNo, Kind);
350350
return false;
351351
}
352352

llvm/lib/IR/Verifier.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,7 @@ void Verifier::visitFunction(const Function &F) {
23482348
case CallingConv::C:
23492349
break;
23502350
case CallingConv::X86_INTR: {
2351-
Assert(F.arg_empty() || Attrs.hasParamAttribute(0, Attribute::ByVal),
2351+
Assert(F.arg_empty() || Attrs.hasParamAttr(0, Attribute::ByVal),
23522352
"Calling convention parameter requires byval", &F);
23532353
break;
23542354
}
@@ -2368,14 +2368,14 @@ void Verifier::visitFunction(const Function &F) {
23682368
const unsigned StackAS = DL.getAllocaAddrSpace();
23692369
unsigned i = 0;
23702370
for (const Argument &Arg : F.args()) {
2371-
Assert(!Attrs.hasParamAttribute(i, Attribute::ByVal),
2371+
Assert(!Attrs.hasParamAttr(i, Attribute::ByVal),
23722372
"Calling convention disallows byval", &F);
2373-
Assert(!Attrs.hasParamAttribute(i, Attribute::Preallocated),
2373+
Assert(!Attrs.hasParamAttr(i, Attribute::Preallocated),
23742374
"Calling convention disallows preallocated", &F);
2375-
Assert(!Attrs.hasParamAttribute(i, Attribute::InAlloca),
2375+
Assert(!Attrs.hasParamAttr(i, Attribute::InAlloca),
23762376
"Calling convention disallows inalloca", &F);
23772377

2378-
if (Attrs.hasParamAttribute(i, Attribute::ByRef)) {
2378+
if (Attrs.hasParamAttr(i, Attribute::ByRef)) {
23792379
// FIXME: Should also disallow LDS and GDS, but we don't have the enum
23802380
// value here.
23812381
Assert(Arg.getType()->getPointerAddressSpace() != StackAS,
@@ -2416,7 +2416,7 @@ void Verifier::visitFunction(const Function &F) {
24162416
}
24172417

24182418
// Check that swifterror argument is only used by loads and stores.
2419-
if (Attrs.hasParamAttribute(i, Attribute::SwiftError)) {
2419+
if (Attrs.hasParamAttr(i, Attribute::SwiftError)) {
24202420
verifySwiftErrorValue(&Arg);
24212421
}
24222422
++i;
@@ -3118,7 +3118,7 @@ void Verifier::visitCallBase(CallBase &Call) {
31183118
Call);
31193119
}
31203120

3121-
if (Attrs.hasParamAttribute(i, Attribute::ImmArg)) {
3121+
if (Attrs.hasParamAttr(i, Attribute::ImmArg)) {
31223122
// Don't allow immarg on call sites, unless the underlying declaration
31233123
// also has the matching immarg.
31243124
Assert(Callee && Callee->hasParamAttribute(i, Attribute::ImmArg),
@@ -3150,9 +3150,9 @@ void Verifier::visitCallBase(CallBase &Call) {
31503150
bool SawReturned = false;
31513151

31523152
for (unsigned Idx = 0; Idx < FTy->getNumParams(); ++Idx) {
3153-
if (Attrs.hasParamAttribute(Idx, Attribute::Nest))
3153+
if (Attrs.hasParamAttr(Idx, Attribute::Nest))
31543154
SawNest = true;
3155-
if (Attrs.hasParamAttribute(Idx, Attribute::Returned))
3155+
if (Attrs.hasParamAttr(Idx, Attribute::Returned))
31563156
SawReturned = true;
31573157
}
31583158

@@ -3329,9 +3329,9 @@ static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) {
33293329
}
33303330

33313331
// `align` is ABI-affecting only in combination with `byval` or `byref`.
3332-
if (Attrs.hasParamAttribute(I, Attribute::Alignment) &&
3333-
(Attrs.hasParamAttribute(I, Attribute::ByVal) ||
3334-
Attrs.hasParamAttribute(I, Attribute::ByRef)))
3332+
if (Attrs.hasParamAttr(I, Attribute::Alignment) &&
3333+
(Attrs.hasParamAttr(I, Attribute::ByVal) ||
3334+
Attrs.hasParamAttr(I, Attribute::ByRef)))
33353335
Copy.addAlignmentAttr(Attrs.getParamAlignment(I));
33363336
return Copy;
33373337
}

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,8 +1825,8 @@ bool isArgPassedInSGPR(const Argument *A) {
18251825
case CallingConv::AMDGPU_Gfx:
18261826
// For non-compute shaders, SGPR inputs are marked with either inreg or byval.
18271827
// Everything else is in VGPRs.
1828-
return F->getAttributes().hasParamAttribute(A->getArgNo(), Attribute::InReg) ||
1829-
F->getAttributes().hasParamAttribute(A->getArgNo(), Attribute::ByVal);
1828+
return F->getAttributes().hasParamAttr(A->getArgNo(), Attribute::InReg) ||
1829+
F->getAttributes().hasParamAttr(A->getArgNo(), Attribute::ByVal);
18301830
default:
18311831
// TODO: Should calls support inreg for SGPR inputs?
18321832
return false;

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
14571457
}
14581458
}
14591459

1460-
if (!PAL.hasParamAttribute(paramIndex, Attribute::ByVal)) {
1460+
if (!PAL.hasParamAttr(paramIndex, Attribute::ByVal)) {
14611461
if (Ty->isAggregateType() || Ty->isVectorTy() || Ty->isIntegerTy(128)) {
14621462
// Just print .param .align <a> .b8 .param[size];
14631463
// <a> = PAL.getparamalignment

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
25302530
// to newly created nodes. The SDNodes for params have to
25312531
// appear in the same order as their order of appearance
25322532
// in the original function. "idx+1" holds that order.
2533-
if (!PAL.hasParamAttribute(i, Attribute::ByVal)) {
2533+
if (!PAL.hasParamAttr(i, Attribute::ByVal)) {
25342534
bool aggregateIsPacked = false;
25352535
if (StructType *STy = dyn_cast<StructType>(Ty))
25362536
aggregateIsPacked = STy->isPacked();

llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ bool WebAssemblyFastISel::fastLowerArguments() {
648648
unsigned I = 0;
649649
for (auto const &Arg : F->args()) {
650650
const AttributeList &Attrs = F->getAttributes();
651-
if (Attrs.hasParamAttribute(I, Attribute::ByVal) ||
652-
Attrs.hasParamAttribute(I, Attribute::SwiftSelf) ||
653-
Attrs.hasParamAttribute(I, Attribute::SwiftError) ||
654-
Attrs.hasParamAttribute(I, Attribute::InAlloca) ||
655-
Attrs.hasParamAttribute(I, Attribute::Nest))
651+
if (Attrs.hasParamAttr(I, Attribute::ByVal) ||
652+
Attrs.hasParamAttr(I, Attribute::SwiftSelf) ||
653+
Attrs.hasParamAttr(I, Attribute::SwiftError) ||
654+
Attrs.hasParamAttr(I, Attribute::InAlloca) ||
655+
Attrs.hasParamAttr(I, Attribute::Nest))
656656
return false;
657657

658658
Type *ArgTy = Arg.getType();
@@ -832,18 +832,18 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) {
832832
return false;
833833

834834
const AttributeList &Attrs = Call->getAttributes();
835-
if (Attrs.hasParamAttribute(I, Attribute::ByVal) ||
836-
Attrs.hasParamAttribute(I, Attribute::SwiftSelf) ||
837-
Attrs.hasParamAttribute(I, Attribute::SwiftError) ||
838-
Attrs.hasParamAttribute(I, Attribute::InAlloca) ||
839-
Attrs.hasParamAttribute(I, Attribute::Nest))
835+
if (Attrs.hasParamAttr(I, Attribute::ByVal) ||
836+
Attrs.hasParamAttr(I, Attribute::SwiftSelf) ||
837+
Attrs.hasParamAttr(I, Attribute::SwiftError) ||
838+
Attrs.hasParamAttr(I, Attribute::InAlloca) ||
839+
Attrs.hasParamAttr(I, Attribute::Nest))
840840
return false;
841841

842842
unsigned Reg;
843843

844-
if (Attrs.hasParamAttribute(I, Attribute::SExt))
844+
if (Attrs.hasParamAttr(I, Attribute::SExt))
845845
Reg = getRegForSignedValue(V);
846-
else if (Attrs.hasParamAttribute(I, Attribute::ZExt))
846+
else if (Attrs.hasParamAttr(I, Attribute::ZExt))
847847
Reg = getRegForUnsignedValue(V);
848848
else
849849
Reg = getRegForValue(V);

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ static bool shouldBeMustTail(const CallInst &CI, const Function &F) {
12621262
Attribute::SwiftSelf, Attribute::SwiftError};
12631263
AttributeList Attrs = CI.getAttributes();
12641264
for (auto AK : ABIAttrs)
1265-
if (Attrs.hasParamAttribute(0, AK))
1265+
if (Attrs.hasParamAttr(0, AK))
12661266
return false;
12671267

12681268
return true;

llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
763763
Params.push_back(I->getType());
764764
ArgAlive[ArgI] = true;
765765
ArgAttrVec.push_back(PAL.getParamAttributes(ArgI));
766-
HasLiveReturnedArg |= PAL.hasParamAttribute(ArgI, Attribute::Returned);
766+
HasLiveReturnedArg |= PAL.hasParamAttr(ArgI, Attribute::Returned);
767767
} else {
768768
++NumArgumentsEliminated;
769769
LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Removing argument "

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,12 +2836,12 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
28362836
if (Call.isInAllocaArgument(i))
28372837
return false; // Cannot transform to and from inalloca.
28382838

2839-
if (CallerPAL.hasParamAttribute(i, Attribute::SwiftError))
2839+
if (CallerPAL.hasParamAttr(i, Attribute::SwiftError))
28402840
return false;
28412841

28422842
// If the parameter is passed as a byval argument, then we have to have a
28432843
// sized type and the sized type has to have the same size as the old type.
2844-
if (ParamTy != ActTy && CallerPAL.hasParamAttribute(i, Attribute::ByVal)) {
2844+
if (ParamTy != ActTy && CallerPAL.hasParamAttr(i, Attribute::ByVal)) {
28452845
PointerType *ParamPTy = dyn_cast<PointerType>(ParamTy);
28462846
if (!ParamPTy || !ParamPTy->getElementType()->isSized())
28472847
return false;
@@ -2911,7 +2911,7 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
29112911
Args.push_back(NewArg);
29122912

29132913
// Add any parameter attributes.
2914-
if (CallerPAL.hasParamAttribute(i, Attribute::ByVal)) {
2914+
if (CallerPAL.hasParamAttr(i, Attribute::ByVal)) {
29152915
AttrBuilder AB(CallerPAL.getParamAttributes(i));
29162916
AB.addByValAttr(NewArg->getType()->getPointerElementType());
29172917
ArgAttrs.push_back(AttributeSet::get(Ctx, AB));

llvm/unittests/IR/AttributesTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ TEST(Attributes, AddMatchingAlignAttr) {
158158
AL = AL.addAttributes(C, AttributeList::FirstArgIndex, B);
159159
EXPECT_EQ(Align(8), AL.getParamAlignment(0));
160160
EXPECT_EQ(Align(32), AL.getParamAlignment(1));
161-
EXPECT_TRUE(AL.hasParamAttribute(0, Attribute::NonNull));
161+
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::NonNull));
162162
}
163163

164164
TEST(Attributes, EmptyGet) {

0 commit comments

Comments
 (0)