[llvm] e6e2983 - [IR] Migrate from getNumArgOperands to arg_size (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 4 08:40:39 PDT 2021
Author: Kazu Hirata
Date: 2021-10-04T08:40:25-07:00
New Revision: e6e29831ddf8bb8ec03472fe69eea91dcc942124
URL: https://github.com/llvm/llvm-project/commit/e6e29831ddf8bb8ec03472fe69eea91dcc942124
DIFF: https://github.com/llvm/llvm-project/commit/e6e29831ddf8bb8ec03472fe69eea91dcc942124.diff
LOG: [IR] Migrate from getNumArgOperands to arg_size (NFC)
Note that arg_operands is considered a legacy name. See
llvm/include/llvm/IR/InstrTypes.h for details.
Added:
Modified:
llvm/include/llvm/IR/AbstractCallSite.h
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Instructions.h
llvm/lib/IR/AbstractCallSite.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/AbstractCallSite.h b/llvm/include/llvm/IR/AbstractCallSite.h
index e8cf05001542..31df4c75b6e7 100644
--- a/llvm/include/llvm/IR/AbstractCallSite.h
+++ b/llvm/include/llvm/IR/AbstractCallSite.h
@@ -153,7 +153,7 @@ class AbstractCallSite {
/// Return the number of parameters of the callee.
unsigned getNumArgOperands() const {
if (isDirectCall())
- return CB->getNumArgOperands();
+ return CB->arg_size();
// Subtract 1 for the callee encoding.
return CI.ParameterEncoding.size() - 1;
}
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 802bc6a85c0b..4546e80fc87a 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1336,22 +1336,22 @@ class CallBase : public Instruction {
unsigned getNumArgOperands() const { return arg_size(); }
Value *getArgOperand(unsigned i) const {
- assert(i < getNumArgOperands() && "Out of bounds!");
+ assert(i < arg_size() && "Out of bounds!");
return getOperand(i);
}
void setArgOperand(unsigned i, Value *v) {
- assert(i < getNumArgOperands() && "Out of bounds!");
+ assert(i < arg_size() && "Out of bounds!");
setOperand(i, v);
}
/// Wrappers for getting the \c Use of a call argument.
const Use &getArgOperandUse(unsigned i) const {
- assert(i < getNumArgOperands() && "Out of bounds!");
+ assert(i < arg_size() && "Out of bounds!");
return User::getOperandUse(i);
}
Use &getArgOperandUse(unsigned i) {
- assert(i < getNumArgOperands() && "Out of bounds!");
+ assert(i < arg_size() && "Out of bounds!");
return User::getOperandUse(i);
}
@@ -1518,13 +1518,13 @@ class CallBase : public Instruction {
/// Adds the attribute to the indicated argument
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
- assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.addParamAttribute(getContext(), ArgNo, Kind);
}
/// Adds the attribute to the indicated argument
void addParamAttr(unsigned ArgNo, Attribute Attr) {
- assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.addParamAttribute(getContext(), ArgNo, Attr);
}
@@ -1560,13 +1560,13 @@ class CallBase : public Instruction {
/// Removes the attribute from the given argument
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
- assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.removeParamAttribute(getContext(), ArgNo, Kind);
}
/// Removes the attribute from the given argument
void removeParamAttr(unsigned ArgNo, StringRef Kind) {
- assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.removeParamAttribute(getContext(), ArgNo, Kind);
}
@@ -1617,13 +1617,13 @@ class CallBase : public Instruction {
/// Get the attribute of a given kind from a given arg
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
- assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ assert(ArgNo < arg_size() && "Out of bounds");
return getAttributes().getParamAttr(ArgNo, Kind);
}
/// Get the attribute of a given kind from a given arg
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
- assert(ArgNo < getNumArgOperands() && "Out of bounds");
+ assert(ArgNo < arg_size() && "Out of bounds");
return getAttributes().getParamAttr(ArgNo, Kind);
}
@@ -1640,14 +1640,14 @@ class CallBase : public Instruction {
/// (\p i) in the operand list.
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const {
// Note that we have to add one because `i` isn't zero-indexed.
- assert(i < getNumArgOperands() + getNumTotalBundleOperands() &&
+ assert(i < arg_size() + getNumTotalBundleOperands() &&
"Data operand index out of bounds!");
// The attribute A can either be directly specified, if the operand in
// question is a call argument; or be indirectly implied by the kind of its
// containing operand bundle, if the operand is a bundle operand.
- if (i < getNumArgOperands())
+ if (i < arg_size())
return paramHasAttr(i, Kind);
assert(hasOperandBundles() && i >= getBundleOperandsStartIndex() &&
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index c5d575d25627..731198da7f40 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -4105,14 +4105,12 @@ class CallBrInst : public CallBase {
///
Value *getIndirectDestLabel(unsigned i) const {
assert(i < getNumIndirectDests() && "Out of bounds!");
- return getOperand(i + getNumArgOperands() + getNumTotalBundleOperands() +
- 1);
+ return getOperand(i + arg_size() + getNumTotalBundleOperands() + 1);
}
Value *getIndirectDestLabelUse(unsigned i) const {
assert(i < getNumIndirectDests() && "Out of bounds!");
- return getOperandUse(i + getNumArgOperands() + getNumTotalBundleOperands() +
- 1);
+ return getOperandUse(i + arg_size() + getNumTotalBundleOperands() + 1);
}
// Return the destination basic blocks...
diff --git a/llvm/lib/IR/AbstractCallSite.cpp b/llvm/lib/IR/AbstractCallSite.cpp
index 6504e566ba4b..2e41799e13e9 100644
--- a/llvm/lib/IR/AbstractCallSite.cpp
+++ b/llvm/lib/IR/AbstractCallSite.cpp
@@ -121,7 +121,7 @@ AbstractCallSite::AbstractCallSite(const Use *U)
assert(CallbackEncMD->getNumOperands() >= 2 && "Incomplete !callback metadata");
- unsigned NumCallOperands = CB->getNumArgOperands();
+ unsigned NumCallOperands = CB->arg_size();
// Skip the var-arg flag at the end when reading the metadata.
for (unsigned u = 0, e = CallbackEncMD->getNumOperands() - 1; u < e; u++) {
Metadata *OpAsM = CallbackEncMD->getOperand(u).get();
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 7d2e515963a0..c668e15dfbe4 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4114,7 +4114,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(Operand, false);
Out << '(';
- for (unsigned op = 0, Eop = CI->getNumArgOperands(); op < Eop; ++op) {
+ for (unsigned op = 0, Eop = CI->arg_size(); op < Eop; ++op) {
if (op > 0)
Out << ", ";
writeParamOperand(CI->getArgOperand(op), PAL.getParamAttrs(op));
@@ -4159,7 +4159,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(Operand, false);
Out << '(';
- for (unsigned op = 0, Eop = II->getNumArgOperands(); op < Eop; ++op) {
+ for (unsigned op = 0, Eop = II->arg_size(); op < Eop; ++op) {
if (op)
Out << ", ";
writeParamOperand(II->getArgOperand(op), PAL.getParamAttrs(op));
@@ -4199,7 +4199,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(Operand, false);
Out << '(';
- for (unsigned op = 0, Eop = CBI->getNumArgOperands(); op < Eop; ++op) {
+ for (unsigned op = 0, Eop = CBI->arg_size(); op < Eop; ++op) {
if (op)
Out << ", ";
writeParamOperand(CBI->getArgOperand(op), PAL.getParamAttrs(op));
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index eebcb0070acb..fc5c59cba974 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1275,7 +1275,7 @@ static Value *UpgradeX86BinaryIntrinsics(IRBuilder<> &Builder, CallInst &CI,
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID, Ty);
Value *Res = Builder.CreateCall(Intrin, {Op0, Op1});
- if (CI.getNumArgOperands() == 4) { // For masked intrinsics.
+ if (CI.arg_size() == 4) { // For masked intrinsics.
Value *VecSrc = CI.getOperand(2);
Value *Mask = CI.getOperand(3);
Res = EmitX86Select(Builder, Mask, Res, VecSrc);
@@ -1302,7 +1302,7 @@ static Value *upgradeX86Rotate(IRBuilder<> &Builder, CallInst &CI,
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID, Ty);
Value *Res = Builder.CreateCall(Intrin, {Src, Src, Amt});
- if (CI.getNumArgOperands() == 4) { // For masked intrinsics.
+ if (CI.arg_size() == 4) { // For masked intrinsics.
Value *VecSrc = CI.getOperand(2);
Value *Mask = CI.getOperand(3);
Res = EmitX86Select(Builder, Mask, Res, VecSrc);
@@ -1372,7 +1372,7 @@ static Value *upgradeX86ConcatShift(IRBuilder<> &Builder, CallInst &CI,
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID, Ty);
Value *Res = Builder.CreateCall(Intrin, {Op0, Op1, Amt});
- unsigned NumArgs = CI.getNumArgOperands();
+ unsigned NumArgs = CI.arg_size();
if (NumArgs >= 4) { // For masked intrinsics.
Value *VecSrc = NumArgs == 5 ? CI.getArgOperand(3) :
ZeroMask ? ConstantAggregateZero::get(CI.getType()) :
@@ -1433,7 +1433,7 @@ static Value *upgradeAbs(IRBuilder<> &Builder, CallInst &CI) {
Value *Op0 = CI.getArgOperand(0);
Function *F = Intrinsic::getDeclaration(CI.getModule(), Intrinsic::abs, Ty);
Value *Res = Builder.CreateCall(F, {Op0, Builder.getInt1(false)});
- if (CI.getNumArgOperands() == 3)
+ if (CI.arg_size() == 3)
Res = EmitX86Select(Builder, CI.getArgOperand(2), Res, CI.getArgOperand(1));
return Res;
}
@@ -1461,7 +1461,7 @@ static Value *upgradePMULDQ(IRBuilder<> &Builder, CallInst &CI, bool IsSigned) {
Value *Res = Builder.CreateMul(LHS, RHS);
- if (CI.getNumArgOperands() == 4)
+ if (CI.arg_size() == 4)
Res = EmitX86Select(Builder, CI.getArgOperand(3), Res, CI.getArgOperand(2));
return Res;
@@ -1516,7 +1516,7 @@ static Value *upgradeMaskedCompare(IRBuilder<> &Builder, CallInst &CI,
Cmp = Builder.CreateICmp(Pred, Op0, CI.getArgOperand(1));
}
- Value *Mask = CI.getArgOperand(CI.getNumArgOperands() - 1);
+ Value *Mask = CI.getArgOperand(CI.arg_size() - 1);
return ApplyX86MaskOn1BitsVec(Builder, Cmp, Mask);
}
@@ -1786,7 +1786,7 @@ static bool upgradeAVX512MaskToSelect(StringRef Name, IRBuilder<> &Builder,
Args.pop_back();
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI.getModule(), IID),
Args);
- unsigned NumArgs = CI.getNumArgOperands();
+ unsigned NumArgs = CI.arg_size();
Rep = EmitX86Select(Builder, CI.getArgOperand(NumArgs - 1), Rep,
CI.getArgOperand(NumArgs - 2));
return true;
@@ -1965,7 +1965,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
CI->getType()),
{CI->getArgOperand(0)});
} else if (IsX86 && (Name.startswith("avx512.mask.sqrt.p"))) {
- if (CI->getNumArgOperands() == 4 &&
+ if (CI->arg_size() == 4 &&
(!isa<ConstantInt>(CI->getArgOperand(3)) ||
cast<ConstantInt>(CI->getArgOperand(3))->getZExtValue() != 4)) {
Intrinsic::ID IID = Name[18] == 's' ? Intrinsic::x86_avx512_sqrt_ps_512
@@ -2257,7 +2257,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
bool IsUnsigned = (StringRef::npos != Name.find("cvtu"));
if (IsPS2PD)
Rep = Builder.CreateFPExt(Rep, DstTy, "cvtps2pd");
- else if (CI->getNumArgOperands() == 4 &&
+ else if (CI->arg_size() == 4 &&
(!isa<ConstantInt>(CI->getArgOperand(3)) ||
cast<ConstantInt>(CI->getArgOperand(3))->getZExtValue() != 4)) {
Intrinsic::ID IID = IsUnsigned ? Intrinsic::x86_avx512_uitofp_round
@@ -2270,7 +2270,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
: Builder.CreateSIToFP(Rep, DstTy, "cvt");
}
- if (CI->getNumArgOperands() >= 3)
+ if (CI->arg_size() >= 3)
Rep = EmitX86Select(Builder, CI->getArgOperand(2), Rep,
CI->getArgOperand(1));
} else if (IsX86 && (Name.startswith("avx512.mask.vcvtph2ps.") ||
@@ -2286,7 +2286,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateBitCast(
Rep, FixedVectorType::get(Type::getHalfTy(C), NumDstElts));
Rep = Builder.CreateFPExt(Rep, DstTy, "cvtph2ps");
- if (CI->getNumArgOperands() >= 3)
+ if (CI->arg_size() >= 3)
Rep = EmitX86Select(Builder, CI->getArgOperand(2), Rep,
CI->getArgOperand(1));
} else if (IsX86 && (Name.startswith("avx512.mask.loadu."))) {
@@ -2353,7 +2353,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
llvm_unreachable("Unknown suffix");
unsigned Imm;
- if (CI->getNumArgOperands() == 3) {
+ if (CI->arg_size() == 3) {
Imm = cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
} else {
Name = Name.substr(9); // strip off "xop.vpcom"
@@ -2442,7 +2442,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = DoSext ? Builder.CreateSExt(SV, DstTy)
: Builder.CreateZExt(SV, DstTy);
// If there are 3 arguments, it's a masked intrinsic so we need a select.
- if (CI->getNumArgOperands() == 3)
+ if (CI->arg_size() == 3)
Rep = EmitX86Select(Builder, CI->getArgOperand(2), Rep,
CI->getArgOperand(1));
} else if (Name == "avx512.mask.pmov.qd.256" ||
@@ -2518,7 +2518,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
ShuffleVectorInst::getShuffleMask(Constant::getNullValue(MaskTy), M);
Rep = Builder.CreateShuffleVector(Op, M);
- if (CI->getNumArgOperands() == 3)
+ if (CI->arg_size() == 3)
Rep = EmitX86Select(Builder, CI->getArgOperand(2), Rep,
CI->getArgOperand(1));
} else if (IsX86 && (Name.startswith("sse2.padds.") ||
@@ -2636,7 +2636,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateShuffleVector(Op0, Rep, Idxs);
// If the intrinsic has a mask operand, handle that.
- if (CI->getNumArgOperands() == 5)
+ if (CI->arg_size() == 5)
Rep = EmitX86Select(Builder, CI->getArgOperand(4), Rep,
CI->getArgOperand(3));
} else if (IsX86 && (Name.startswith("avx.vextractf128.") ||
@@ -2661,7 +2661,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateShuffleVector(Op0, Op0, Idxs);
// If the intrinsic has a mask operand, handle that.
- if (CI->getNumArgOperands() == 4)
+ if (CI->arg_size() == 4)
Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
CI->getArgOperand(2));
} else if (!IsX86 && Name == "stackprotectorcheck") {
@@ -2679,7 +2679,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateShuffleVector(Op0, Op0, Idxs);
- if (CI->getNumArgOperands() == 4)
+ if (CI->arg_size() == 4)
Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
CI->getArgOperand(2));
} else if (IsX86 && (Name.startswith("avx.vperm2f128.") ||
@@ -2739,7 +2739,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateShuffleVector(Op0, Op0, Idxs);
- if (CI->getNumArgOperands() == 4)
+ if (CI->arg_size() == 4)
Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
CI->getArgOperand(2));
} else if (IsX86 && (Name == "sse2.pshufl.w" ||
@@ -2758,7 +2758,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateShuffleVector(Op0, Op0, Idxs);
- if (CI->getNumArgOperands() == 4)
+ if (CI->arg_size() == 4)
Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
CI->getArgOperand(2));
} else if (IsX86 && (Name == "sse2.pshufh.w" ||
@@ -2777,7 +2777,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Rep = Builder.CreateShuffleVector(Op0, Op0, Idxs);
- if (CI->getNumArgOperands() == 4)
+ if (CI->arg_size() == 4)
Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
CI->getArgOperand(2));
} else if (IsX86 && Name.startswith("avx512.mask.shuf.p")) {
@@ -3346,7 +3346,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
if (NegAcc)
C = Builder.CreateFNeg(C);
- if (CI->getNumArgOperands() == 5 &&
+ if (CI->arg_size() == 5 &&
(!isa<ConstantInt>(CI->getArgOperand(4)) ||
cast<ConstantInt>(CI->getArgOperand(4))->getZExtValue() != 4)) {
Intrinsic::ID IID;
@@ -3399,7 +3399,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
// Drop the "avx512.mask." to make it easier.
Name = Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
bool IsSubAdd = Name[3] == 's';
- if (CI->getNumArgOperands() == 5) {
+ if (CI->arg_size() == 5) {
Intrinsic::ID IID;
// Check the character before ".512" in string.
if (Name[Name.size()-5] == 's')
@@ -3700,7 +3700,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
case Intrinsic::aarch64_neon_bfmlalb:
case Intrinsic::aarch64_neon_bfmlalt: {
SmallVector<Value *, 3> Args;
- assert(CI->getNumArgOperands() == 3 &&
+ assert(CI->arg_size() == 3 &&
"Mismatch between function args and call args");
size_t OperandWidth =
CI->getArgOperand(1)->getType()->getPrimitiveSizeInBits();
@@ -3721,18 +3721,17 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
case Intrinsic::ctlz:
case Intrinsic::cttz:
- assert(CI->getNumArgOperands() == 1 &&
+ assert(CI->arg_size() == 1 &&
"Mismatch between function args and call args");
NewCall =
Builder.CreateCall(NewFn, {CI->getArgOperand(0), Builder.getFalse()});
break;
case Intrinsic::objectsize: {
- Value *NullIsUnknownSize = CI->getNumArgOperands() == 2
- ? Builder.getFalse()
- : CI->getArgOperand(2);
+ Value *NullIsUnknownSize =
+ CI->arg_size() == 2 ? Builder.getFalse() : CI->getArgOperand(2);
Value *Dynamic =
- CI->getNumArgOperands() < 4 ? Builder.getFalse() : CI->getArgOperand(3);
+ CI->arg_size() < 4 ? Builder.getFalse() : CI->getArgOperand(3);
NewCall = Builder.CreateCall(
NewFn, {CI->getArgOperand(0), CI->getArgOperand(1), NullIsUnknownSize, Dynamic});
break;
@@ -3748,7 +3747,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
case Intrinsic::dbg_value:
// Upgrade from the old version that had an extra offset argument.
- assert(CI->getNumArgOperands() == 4);
+ assert(CI->arg_size() == 4);
// Drop nonzero offsets instead of attempting to upgrade them.
if (auto *Offset = dyn_cast_or_null<Constant>(CI->getArgOperand(1)))
if (Offset->isZeroValue()) {
@@ -3762,7 +3761,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
case Intrinsic::ptr_annotation:
// Upgrade from versions that lacked the annotation attribute argument.
- assert(CI->getNumArgOperands() == 4 &&
+ assert(CI->arg_size() == 4 &&
"Before LLVM 12.0 this intrinsic took four arguments");
// Create a new call with an added null annotation attribute argument.
NewCall = Builder.CreateCall(
@@ -3776,7 +3775,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
case Intrinsic::var_annotation:
// Upgrade from versions that lacked the annotation attribute argument.
- assert(CI->getNumArgOperands() == 4 &&
+ assert(CI->arg_size() == 4 &&
"Before LLVM 12.0 this intrinsic took four arguments");
// Create a new call with an added null annotation attribute argument.
NewCall = Builder.CreateCall(
@@ -3915,7 +3914,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
// @llvm.memset...(i8*, i8, i[32|64], i32, i1)
// -> @llvm.memset...(i8*, i8, i[32|64], i1)
// Note: i8*'s in the above can be any pointer type
- if (CI->getNumArgOperands() != 5) {
+ if (CI->arg_size() != 5) {
DefaultCase();
return;
}
@@ -4105,7 +4104,7 @@ void llvm::UpgradeARCRuntime(Module &M) {
bool InvalidCast = false;
- for (unsigned I = 0, E = CI->getNumArgOperands(); I != E; ++I) {
+ for (unsigned I = 0, E = CI->arg_size(); I != E; ++I) {
Value *Arg = CI->getArgOperand(I);
// Bitcast argument to the parameter type of the new function if it's
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 5ef4204f5bc3..4705a06c35b6 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -2844,7 +2844,7 @@ unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
return FPI->getNumArgOperands();
}
- return unwrap<CallBase>(Instr)->getNumArgOperands();
+ return unwrap<CallBase>(Instr)->arg_size();
}
/*--.. Call and invoke instructions ........................................--*/
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index fdeb8bdd8539..25d0440215b3 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -178,7 +178,7 @@ void Instruction::dropUndefImplyingAttrsAndUnknownMetadata(
if (AL.isEmpty())
return;
AttrBuilder UBImplyingAttributes = AttributeFuncs::getUBImplyingAttributes();
- for (unsigned ArgNo = 0; ArgNo < CB->getNumArgOperands(); ArgNo++)
+ for (unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
CB->removeParamAttrs(ArgNo, UBImplyingAttributes);
CB->removeRetAttrs(UBImplyingAttributes);
}
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 38e481c7faf2..83be43261b3d 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -339,7 +339,7 @@ Value *CallBase::getReturnedArgOperand() const {
/// Determine whether the argument or parameter has the given attribute.
bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
- assert(ArgNo < getNumArgOperands() && "Param index out of bounds!");
+ assert(ArgNo < arg_size() && "Param index out of bounds!");
if (Attrs.hasParamAttr(ArgNo, Kind))
return true;
@@ -943,7 +943,7 @@ void CallBrInst::updateArgBlockAddresses(unsigned i, BasicBlock *B) {
if (BasicBlock *OldBB = getIndirectDest(i)) {
BlockAddress *Old = BlockAddress::get(OldBB);
BlockAddress *New = BlockAddress::get(B);
- for (unsigned ArgNo = 0, e = getNumArgOperands(); ArgNo != e; ++ArgNo)
+ for (unsigned ArgNo = 0, e = arg_size(); ArgNo != e; ++ArgNo)
if (dyn_cast<BlockAddress>(getArgOperand(ArgNo)) == Old)
setArgOperand(ArgNo, New);
}
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 56dfedcdf7b5..5b6636db450b 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -188,7 +188,7 @@ Value *InstrProfIncrementInst::getStep() const {
}
Optional<RoundingMode> ConstrainedFPIntrinsic::getRoundingMode() const {
- unsigned NumOperands = getNumArgOperands();
+ unsigned NumOperands = arg_size();
Metadata *MD = nullptr;
auto *MAV = dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 2));
if (MAV)
@@ -200,7 +200,7 @@ Optional<RoundingMode> ConstrainedFPIntrinsic::getRoundingMode() const {
Optional<fp::ExceptionBehavior>
ConstrainedFPIntrinsic::getExceptionBehavior() const {
- unsigned NumOperands = getNumArgOperands();
+ unsigned NumOperands = arg_size();
Metadata *MD = nullptr;
auto *MAV = dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 1));
if (MAV)
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index f245c94dfda8..390f13643b28 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2732,7 +2732,7 @@ void Verifier::visitCallBrInst(CallBrInst &CBI) {
Assert(CBI.getSuccessor(i)->getType()->isLabelTy(),
"Callbr successors must all have pointer type!", &CBI);
for (unsigned i = 0, e = CBI.getNumOperands(); i != e; ++i) {
- Assert(i >= CBI.getNumArgOperands() || !isa<BasicBlock>(CBI.getOperand(i)),
+ Assert(i >= CBI.arg_size() || !isa<BasicBlock>(CBI.getOperand(i)),
"Using an unescaped label as a callbr argument!", &CBI);
if (isa<BasicBlock>(CBI.getOperand(i)))
for (unsigned j = i + 1; j != e; ++j)
@@ -4789,7 +4789,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
"llvm.call.preallocated.setup");
FoundCall = true;
size_t NumPreallocatedArgs = 0;
- for (unsigned i = 0; i < UseCall->getNumArgOperands(); i++) {
+ for (unsigned i = 0; i < UseCall->arg_size(); i++) {
if (UseCall->paramHasAttr(i, Attribute::Preallocated)) {
++NumPreallocatedArgs;
}
@@ -4887,7 +4887,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
Assert(AI && AI->isStaticAlloca(),
"llvm.localescape only accepts static allocas", Call);
}
- FrameEscapeInfo[BB->getParent()].first = Call.getNumArgOperands();
+ FrameEscapeInfo[BB->getParent()].first = Call.arg_size();
SawFrameEscape = true;
break;
}
@@ -4936,7 +4936,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
break;
}
case Intrinsic::experimental_gc_relocate: {
- Assert(Call.getNumArgOperands() == 3, "wrong number of arguments", Call);
+ Assert(Call.arg_size() == 3, "wrong number of arguments", Call);
Assert(isa<PointerType>(Call.getType()->getScalarType()),
"gc.relocate must return a pointer or a vector of pointers", Call);
@@ -5393,7 +5393,7 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
// Compare intrinsics carry an extra predicate metadata operand.
if (isa<ConstrainedFPCmpIntrinsic>(FPI))
NumOperands += 1;
- Assert((FPI.getNumArgOperands() == NumOperands),
+ Assert((FPI.arg_size() == NumOperands),
"invalid arguments for constrained FP intrinsic", &FPI);
switch (FPI.getIntrinsicID()) {
More information about the llvm-commits
mailing list