From d34cd75d890ae18beae8b40079522935b5fcf45a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 3 Oct 2021 08:22:19 -0700 Subject: [PATCH] [Analysis, CodeGen] Migrate from arg_operands to args (NFC) Note that arg_operands is considered a legacy name. See llvm/include/llvm/IR/InstrTypes.h for details. --- llvm/lib/Analysis/AliasAnalysis.cpp | 2 +- llvm/lib/Analysis/BasicAliasAnalysis.cpp | 3 +-- llvm/lib/Analysis/ConstantFolding.cpp | 4 ++-- llvm/lib/Analysis/InstructionSimplify.cpp | 4 ++-- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 5 ++--- llvm/lib/CodeGen/IntrinsicLowering.cpp | 3 +-- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 4 ++-- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 16 ++++++++-------- llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 2 +- llvm/lib/CodeGen/TypePromotion.cpp | 6 ++---- 10 files changed, 22 insertions(+), 27 deletions(-) diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 04d71d4..d030f74 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -745,7 +745,7 @@ ModRefInfo AAResults::callCapturesBefore(const Instruction *I, // pointer were passed to arguments that were neither of these, then it // couldn't be no-capture. if (!(*CI)->getType()->isPointerTy() || - (!Call->doesNotCapture(ArgNo) && ArgNo < Call->getNumArgOperands() && + (!Call->doesNotCapture(ArgNo) && ArgNo < Call->arg_size() && !Call->isByValArgument(ArgNo))) continue; diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 5d9a5f6..705091c 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -969,8 +969,7 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call, // pointer were passed to arguments that were neither of these, then it // couldn't be no-capture. if (!(*CI)->getType()->isPointerTy() || - (!Call->doesNotCapture(OperandNo) && - OperandNo < Call->getNumArgOperands() && + (!Call->doesNotCapture(OperandNo) && OperandNo < Call->arg_size() && !Call->isByValArgument(OperandNo))) continue; diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 2543670..3926776 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -3171,7 +3171,7 @@ bool llvm::isMathLibCallNoop(const CallBase *Call, if (!TLI || !TLI->getLibFunc(*F, Func)) return false; - if (Call->getNumArgOperands() == 1) { + if (Call->arg_size() == 1) { if (ConstantFP *OpC = dyn_cast(Call->getArgOperand(0))) { const APFloat &Op = OpC->getValueAPF(); switch (Func) { @@ -3260,7 +3260,7 @@ bool llvm::isMathLibCallNoop(const CallBase *Call, } } - if (Call->getNumArgOperands() == 2) { + if (Call->arg_size() == 2) { ConstantFP *Op0C = dyn_cast(Call->getArgOperand(0)); ConstantFP *Op1C = dyn_cast(Call->getArgOperand(1)); if (Op0C && Op1C) { diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index ed6425fa..200523f 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -5811,7 +5811,7 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, static Value *simplifyIntrinsic(CallBase *Call, const SimplifyQuery &Q) { - unsigned NumOperands = Call->getNumArgOperands(); + unsigned NumOperands = Call->arg_size(); Function *F = cast(Call->getCalledFunction()); Intrinsic::ID IID = F->getIntrinsicID(); @@ -6006,7 +6006,7 @@ static Value *tryConstantFoldCall(CallBase *Call, const SimplifyQuery &Q) { return nullptr; SmallVector ConstantArgs; - unsigned NumArgs = Call->getNumArgOperands(); + unsigned NumArgs = Call->arg_size(); ConstantArgs.reserve(NumArgs); for (auto &Arg : Call->args()) { Constant *C = dyn_cast(&Arg); diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 940766e..ee4fa8c 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -1591,8 +1591,7 @@ bool IRTranslator::translateMemFunc(const CallInst &CI, Align DstAlign; Align SrcAlign; unsigned IsVol = - cast(CI.getArgOperand(CI.getNumArgOperands() - 1)) - ->getZExtValue(); + cast(CI.getArgOperand(CI.arg_size() - 1))->getZExtValue(); if (auto *MCI = dyn_cast(&CI)) { DstAlign = MCI->getDestAlign().valueOrOne(); @@ -2177,7 +2176,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, // Directly emit some LOCAL_ESCAPE machine instrs. Label assignment emission // is the same on all targets. - for (unsigned Idx = 0, E = CI.getNumArgOperands(); Idx < E; ++Idx) { + for (unsigned Idx = 0, E = CI.arg_size(); Idx < E; ++Idx) { Value *Arg = CI.getArgOperand(Idx)->stripPointerCasts(); if (isa(Arg)) continue; // Skip null pointers. They represent a hole in index space. diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp b/llvm/lib/CodeGen/IntrinsicLowering.cpp index 55089d3..808a79d 100644 --- a/llvm/lib/CodeGen/IntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/IntrinsicLowering.cpp @@ -453,8 +453,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { // Verify this is a simple bswap. - if (CI->getNumArgOperands() != 1 || - CI->getType() != CI->getArgOperand(0)->getType() || + if (CI->arg_size() != 1 || CI->getType() != CI->getArgOperand(0)->getType() || !CI->getType()->isIntegerTy()) return false; diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 7af0db1..ee81f59 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -623,7 +623,7 @@ bool FastISel::selectGetElementPtr(const User *I) { bool FastISel::addStackMapLiveVars(SmallVectorImpl &Ops, const CallInst *CI, unsigned StartIdx) { - for (unsigned i = StartIdx, e = CI->getNumArgOperands(); i != e; ++i) { + for (unsigned i = StartIdx, e = CI->arg_size(); i != e; ++i) { Value *Val = CI->getArgOperand(i); // Check for constants and encode them with a StackMaps::ConstantOp prefix. if (const auto *C = dyn_cast(Val)) { @@ -785,7 +785,7 @@ bool FastISel::selectPatchpoint(const CallInst *I) { // Skip the four meta args: , , , // This includes all meta-operands up to but not including CC. unsigned NumMetaOpers = PatchPointOpers::CCPos; - assert(I->getNumArgOperands() >= NumMetaOpers + NumArgs && + assert(I->arg_size() >= NumMetaOpers + NumArgs && "Not enough arguments provided to the patchpoint intrinsic"); // For AnyRegCC the arguments are lowered later on manually. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 77e334a..f19d11d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4790,7 +4790,7 @@ void SelectionDAGBuilder::visitTargetIntrinsic(const CallInst &I, TLI.getPointerTy(DAG.getDataLayout()))); // Add all operands of the call to the operand list. - for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) { + for (unsigned i = 0, e = I.arg_size(); i != e; ++i) { const Value *Arg = I.getArgOperand(i); if (!I.paramHasAttr(i, Attribute::ImmArg)) { Ops.push_back(getValue(Arg)); @@ -6885,7 +6885,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, // Directly emit some LOCAL_ESCAPE machine instrs. Label assignment emission // is the same on all targets. - for (unsigned Idx = 0, E = I.getNumArgOperands(); Idx < E; ++Idx) { + for (unsigned Idx = 0, E = I.arg_size(); Idx < E; ++Idx) { Value *Arg = I.getArgOperand(Idx)->stripPointerCasts(); if (isa(Arg)) continue; // Skip null pointers. They represent a hole in index space. @@ -7055,7 +7055,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, }; SmallVector Targets; - for (unsigned Op = 1, N = I.getNumArgOperands(); Op != N; Op += 2) { + for (unsigned Op = 1, N = I.arg_size(); Op != N; Op += 2) { auto *ElemBase = dyn_cast(GetPointerBaseWithConstantOffset( I.getArgOperand(Op), Offset, DAG.getDataLayout())); if (ElemBase != Base) @@ -7465,7 +7465,7 @@ void SelectionDAGBuilder::visitVectorPredicationIntrinsic( // Request operands. SmallVector OpValues; - for (unsigned I = 0; I < VPIntrin.getNumArgOperands(); ++I) { + for (unsigned I = 0; I < VPIntrin.arg_size(); ++I) { auto Op = getValue(VPIntrin.getArgOperand(I)); if (I == EVLParamPos) Op = DAG.getNode(ISD::ZERO_EXTEND, DL, EVLParamVT, Op); @@ -8583,12 +8583,12 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call, // Process the call argument. BasicBlocks are labels, currently appearing // only in asm's. if (isa(Call) && - ArgNo - 1 >= (cast(&Call)->getNumArgOperands() - + ArgNo - 1 >= (cast(&Call)->arg_size() - cast(&Call)->getNumIndirectDests() - NumMatchingOps) && (NumMatchingOps == 0 || - ArgNo - 1 < (cast(&Call)->getNumArgOperands() - - NumMatchingOps))) { + ArgNo - 1 < + (cast(&Call)->arg_size() - NumMatchingOps))) { const auto *BA = cast(OpInfo.CallOperandVal); EVT VT = TLI.getValueType(DAG.getDataLayout(), BA->getType(), true); OpInfo.CallOperand = DAG.getTargetBlockAddress(BA, VT); @@ -9450,7 +9450,7 @@ void SelectionDAGBuilder::visitVectorReduce(const CallInst &I, const TargetLowering &TLI = DAG.getTargetLoweringInfo(); SDValue Op1 = getValue(I.getArgOperand(0)); SDValue Op2; - if (I.getNumArgOperands() > 1) + if (I.arg_size() > 1) Op2 = getValue(I.getArgOperand(1)); SDLoc dl = getCurSDLoc(); EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType()); diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index a903c24..e2db963 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -1119,7 +1119,7 @@ void SelectionDAGBuilder::LowerCallSiteWithDeoptBundleImpl( StatepointLoweringInfo SI(DAG); unsigned ArgBeginIndex = Call->arg_begin() - Call->op_begin(); populateCallLoweringInfo( - SI.CLI, Call, ArgBeginIndex, Call->getNumArgOperands(), Callee, + SI.CLI, Call, ArgBeginIndex, Call->arg_size(), Callee, ForceVoidReturnTy ? Type::getVoidTy(*DAG.getContext()) : Call->getType(), false); if (!VarArgDisallowed) diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp index df4d71b..bad5a03 100644 --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -568,7 +568,7 @@ void IRPromoter::TruncateSinks() { // Handle calls separately as we need to iterate over arg operands. if (auto *Call = dyn_cast(I)) { - for (unsigned i = 0; i < Call->getNumArgOperands(); ++i) { + for (unsigned i = 0; i < Call->arg_size(); ++i) { Value *Arg = Call->getArgOperand(i); Type *Ty = TruncTysMap[Call][i]; if (Instruction *Trunc = InsertTrunc(Arg, Ty)) { @@ -671,10 +671,8 @@ void IRPromoter::Mutate() { // Cache original types of the values that will likely need truncating for (auto *I : Sinks) { if (auto *Call = dyn_cast(I)) { - for (unsigned i = 0; i < Call->getNumArgOperands(); ++i) { - Value *Arg = Call->getArgOperand(i); + for (Value *Arg : Call->args()) TruncTysMap[Call].push_back(Arg->getType()); - } } else if (auto *Switch = dyn_cast(I)) TruncTysMap[I].push_back(Switch->getCondition()->getType()); else { -- 2.7.4