Index: include/llvm/IR/Argument.h =================================================================== --- include/llvm/IR/Argument.h +++ include/llvm/IR/Argument.h @@ -37,9 +37,8 @@ void setParent(Function *parent); public: - /// If \p F is specified, the argument is inserted at the end of the argument - /// list for \p F. - explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr); + /// Argument constructor. + explicit Argument(Type *Ty, const Twine &Name = ""); inline const Function *getParent() const { return Parent; } inline Function *getParent() { return Parent; } Index: include/llvm/IR/Function.h =================================================================== --- include/llvm/IR/Function.h +++ include/llvm/IR/Function.h @@ -509,22 +509,13 @@ /// Requires that this has no function body. void stealArgumentListFrom(Function &Src); - /// Get the underlying elements of the Function... the basic block list is - /// empty for external functions. - /// - const ArgumentListType &getArgumentList() const { - CheckLazyArguments(); - return ArgumentList; - } - ArgumentListType &getArgumentList() { - CheckLazyArguments(); - return ArgumentList; - } - static ArgumentListType Function::*getSublistAccess(Argument*) { return &Function::ArgumentList; } + /// Get the underlying elements of the Function... the basic block list is + /// empty for external functions. + /// const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; } BasicBlockListType &getBasicBlockList() { return BasicBlocks; } Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -8000,7 +8000,7 @@ // entries as we have arguments. enum StaticAllocaInfo { Unknown, Clobbered, Elidable }; SmallDenseMap StaticAllocas; - unsigned NumArgs = FuncInfo->Fn->getArgumentList().size(); + unsigned NumArgs = FuncInfo->Fn->arg_size(); StaticAllocas.reserve(NumArgs * 2); auto GetInfoIfStaticAlloca = [&](const Value *V) -> StaticAllocaInfo * { Index: lib/IR/Function.cpp =================================================================== --- lib/IR/Function.cpp +++ lib/IR/Function.cpp @@ -39,12 +39,8 @@ void Argument::anchor() { } -Argument::Argument(Type *Ty, const Twine &Name, Function *Par) - : Value(Ty, Value::ArgumentVal) { - Parent = nullptr; - - if (Par) - Par->getArgumentList().push_back(this); +Argument::Argument(Type *Ty, const Twine &Name) + : Value(Ty, Value::ArgumentVal), Parent(nullptr) { setName(Name); } Index: lib/Target/AArch64/AArch64CallLowering.cpp =================================================================== --- lib/Target/AArch64/AArch64CallLowering.cpp +++ lib/Target/AArch64/AArch64CallLowering.cpp @@ -238,7 +238,6 @@ bool AArch64CallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef VRegs) const { - auto &Args = F.getArgumentList(); MachineFunction &MF = MIRBuilder.getMF(); MachineBasicBlock &MBB = MIRBuilder.getMBB(); MachineRegisterInfo &MRI = MF.getRegInfo(); @@ -246,7 +245,7 @@ SmallVector SplitArgs; unsigned i = 0; - for (auto &Arg : Args) { + for (auto &Arg : F.args()) { ArgInfo OrigArg{VRegs[i], Arg.getType()}; setArgFlags(OrigArg, i + 1, DL, F); bool Split = false; Index: lib/Target/ARM/ARMCallLowering.cpp =================================================================== --- lib/Target/ARM/ARMCallLowering.cpp +++ lib/Target/ARM/ARMCallLowering.cpp @@ -337,8 +337,7 @@ if (Subtarget->useSoftFloat() || !Subtarget->hasVFP2()) return false; - auto &Args = F.getArgumentList(); - for (auto &Arg : Args) + for (auto &Arg : F.args()) if (!isSupportedType(DL, TLI, Arg.getType())) return false; @@ -347,7 +346,7 @@ SmallVector ArgInfos; unsigned Idx = 0; - for (auto &Arg : Args) { + for (auto &Arg : F.args()) { ArgInfo AInfo(VRegs[Idx], Arg.getType()); setArgFlags(AInfo, Idx + 1, DL, F); splitToValueTypes(AInfo, ArgInfos, DL, MF.getRegInfo()); Index: lib/Target/AVR/AVRInstrumentFunctions.cpp =================================================================== --- lib/Target/AVR/AVRInstrumentFunctions.cpp +++ lib/Target/AVR/AVRInstrumentFunctions.cpp @@ -96,7 +96,7 @@ Value *FunctionName = CreateStringPtr(BB, F.getName()); Value *Args[] = {FunctionName, - ConstantInt::get(I16, F.getArgumentList().size())}; + ConstantInt::get(I16, F.arg_size())}; CallInst::Create(Fn, Args, "", &BB); } Index: lib/Target/Mips/MipsOs16.cpp =================================================================== --- lib/Target/Mips/MipsOs16.cpp +++ lib/Target/Mips/MipsOs16.cpp @@ -57,7 +57,7 @@ ; } if (F.arg_size() >=1) { - Argument &Arg = F.getArgumentList().front(); + Argument &Arg = *F.arg_begin(); switch (Arg.getType()->getTypeID()) { case Type::FloatTyID: case Type::DoubleTyID: Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -4111,7 +4111,7 @@ static bool hasSameArgumentList(const Function *CallerFn, ImmutableCallSite *CS) { - if (CS->arg_size() != CallerFn->getArgumentList().size()) + if (CS->arg_size() != CallerFn->arg_size()) return false; ImmutableCallSite::arg_iterator CalleeArgIter = CS->arg_begin(); Index: lib/Target/X86/X86CallLowering.cpp =================================================================== --- lib/Target/X86/X86CallLowering.cpp +++ lib/Target/X86/X86CallLowering.cpp @@ -179,7 +179,7 @@ SmallVector SplitArgs; unsigned Idx = 0; - for (auto &Arg : F.getArgumentList()) { + for (auto &Arg : F.args()) { ArgInfo OrigArg(VRegs[Idx], Arg.getType()); setArgFlags(OrigArg, Idx + 1, DL, F); LLT Ty = MRI.getType(VRegs[Idx]); Index: lib/Transforms/Coroutines/CoroElide.cpp =================================================================== --- lib/Transforms/Coroutines/CoroElide.cpp +++ lib/Transforms/Coroutines/CoroElide.cpp @@ -92,7 +92,7 @@ // Given a resume function @f.resume(%f.frame* %frame), returns %f.frame type. static Type *getFrameType(Function *Resume) { - auto *ArgType = Resume->getArgumentList().front().getType(); + auto *ArgType = Resume->arg_begin()->getType(); return cast(ArgType)->getElementType(); } Index: lib/Transforms/Coroutines/CoroFrame.cpp =================================================================== --- lib/Transforms/Coroutines/CoroFrame.cpp +++ lib/Transforms/Coroutines/CoroFrame.cpp @@ -707,7 +707,7 @@ // Collect the spills for arguments and other not-materializable values. Spills.clear(); - for (Argument &A : F.getArgumentList()) + for (Argument &A : F.args()) for (User *U : A.users()) if (Checker.isDefinitionAcrossSuspend(A, U)) Spills.emplace_back(&A, U); Index: lib/Transforms/Coroutines/CoroSplit.cpp =================================================================== --- lib/Transforms/Coroutines/CoroSplit.cpp +++ lib/Transforms/Coroutines/CoroSplit.cpp @@ -223,7 +223,7 @@ // Replace all args with undefs. The buildCoroutineFrame algorithm already // rewritten access to the args that occurs after suspend points with loads // and stores to/from the coroutine frame. - for (Argument &A : F.getArgumentList()) + for (Argument &A : F.args()) VMap[&A] = UndefValue::get(A.getType()); SmallVector Returns; @@ -264,7 +264,7 @@ IRBuilder<> Builder(&NewF->getEntryBlock().front()); // Remap frame pointer. - Argument *NewFramePtr = &NewF->getArgumentList().front(); + Argument *NewFramePtr = &*NewF->arg_begin(); Value *OldFramePtr = cast(VMap[Shape.FramePtr]); NewFramePtr->takeName(OldFramePtr); OldFramePtr->replaceAllUsesWith(NewFramePtr); Index: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -580,8 +580,7 @@ Function::arg_iterator AI = F->arg_begin(); ++AI; for (unsigned N = FT->getNumParams(); N != 0; ++AI, --N) Args.push_back(&*AI); - CallInst *CI = - CallInst::Create(&F->getArgumentList().front(), Args, "", BB); + CallInst *CI = CallInst::Create(&*F->arg_begin(), Args, "", BB); ReturnInst *RI; if (FT->getReturnType()->isVoidTy()) RI = ReturnInst::Create(*Ctx, BB); @@ -595,7 +594,7 @@ DFSanVisitor(DFSF).visitCallInst(*CI); if (!FT->getReturnType()->isVoidTy()) new StoreInst(DFSF.getShadow(RI->getReturnValue()), - &F->getArgumentList().back(), RI); + &*std::prev(F->arg_end()), RI); } return C; @@ -906,7 +905,7 @@ break; } case DataFlowSanitizer::IA_Args: { - unsigned ArgIdx = A->getArgNo() + F->getArgumentList().size() / 2; + unsigned ArgIdx = A->getArgNo() + F->arg_size() / 2; Function::arg_iterator i = F->arg_begin(); while (ArgIdx--) ++i; Index: lib/Transforms/Utils/InlineFunction.cpp =================================================================== --- lib/Transforms/Utils/InlineFunction.cpp +++ lib/Transforms/Utils/InlineFunction.cpp @@ -1603,7 +1603,7 @@ // matches up the formal to the actual argument values. CallSite::arg_iterator AI = CS.arg_begin(); unsigned ArgNo = 0; - for (Function::const_arg_iterator I = CalledFunc->arg_begin(), + for (Function::arg_iterator I = CalledFunc->arg_begin(), E = CalledFunc->arg_end(); I != E; ++I, ++AI, ++ArgNo) { Value *ActualArg = *AI; Index: unittests/IR/ValueTest.cpp =================================================================== --- unittests/IR/ValueTest.cpp +++ unittests/IR/ValueTest.cpp @@ -40,7 +40,7 @@ Function *F = M->getFunction("f"); EXPECT_FALSE(F->isUsedInBasicBlock(&F->front())); - EXPECT_TRUE((++F->arg_begin())->isUsedInBasicBlock(&F->front())); + EXPECT_TRUE(std::next(F->arg_begin())->isUsedInBasicBlock(&F->front())); EXPECT_TRUE(F->arg_begin()->isUsedInBasicBlock(&F->front())); } Index: unittests/Transforms/Utils/IntegerDivision.cpp =================================================================== --- unittests/Transforms/Utils/IntegerDivision.cpp +++ unittests/Transforms/Utils/IntegerDivision.cpp @@ -29,7 +29,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt32Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -59,7 +59,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt32Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -89,7 +89,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt32Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -119,7 +119,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt32Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -150,7 +150,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt64Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -180,7 +180,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt64Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -210,7 +210,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt64Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB); @@ -240,7 +240,7 @@ Function *F = Function::Create(FunctionType::get(Builder.getInt64Ty(), ArgTys, false), GlobalValue::ExternalLinkage, "F", &M); - assert(F->getArgumentList().size() == 2); + assert(F->arg_size() == 2); BasicBlock *BB = BasicBlock::Create(C, "", F); Builder.SetInsertPoint(BB);