From db991cb068bcf148dd1bf46050fb9da51d83d66a Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 20 Oct 2015 00:54:09 +0000 Subject: [PATCH] NVPTX: Remove implicit ilist iterator conversions, NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250779 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 7 +++---- lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp | 8 ++++---- lib/Target/NVPTX/NVPTXGenericToNVVM.cpp | 10 ++++------ lib/Target/NVPTX/NVPTXISelLowering.cpp | 7 +++---- lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp | 4 ++-- lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp | 7 +++---- lib/Target/NVPTX/NVPTXUtilities.cpp | 2 +- 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index a754f00d988..e8c36089a77 100644 --- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -718,7 +718,7 @@ static bool useFuncSeen(const Constant *C, void NVPTXAsmPrinter::emitDeclarations(const Module &M, raw_ostream &O) { llvm::DenseMap seenMap; for (Module::const_iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) { - const Function *F = FI; + const Function *F = &*FI; if (F->isDeclaration()) { if (F->use_empty()) @@ -868,9 +868,8 @@ void NVPTXAsmPrinter::emitGlobals(const Module &M) { DenseSet GVVisiting; // Visit each global variable, in order - for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - VisitGlobalVariableForEmission(I, Globals, GVVisited, GVVisiting); + for (const GlobalVariable &I : M.globals()) + VisitGlobalVariableForEmission(&I, Globals, GVVisited, GVVisiting); assert(GVVisited.size() == M.getGlobalList().size() && "Missed a global variable"); diff --git a/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp b/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp index 781900a2e79..95813c8430d 100644 --- a/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp +++ b/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp @@ -267,14 +267,14 @@ bool NVPTXFavorNonGenericAddrSpaces::runOnFunction(Function &F) { return false; bool Changed = false; - for (Function::iterator B = F.begin(), BE = F.end(); B != BE; ++B) { - for (BasicBlock::iterator I = B->begin(), IE = B->end(); I != IE; ++I) { + for (BasicBlock &B : F) { + for (Instruction &I : B) { if (isa(I)) { // V = load P - Changed |= optimizeMemoryInstruction(I, 0); + Changed |= optimizeMemoryInstruction(&I, 0); } else if (isa(I)) { // store V, P - Changed |= optimizeMemoryInstruction(I, 1); + Changed |= optimizeMemoryInstruction(&I, 1); } } } diff --git a/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp b/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp index 6fd09c40526..dff507f76ba 100644 --- a/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp +++ b/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp @@ -81,7 +81,7 @@ bool GenericToNVVM::runOnModule(Module &M) { for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E;) { - GlobalVariable *GV = I++; + GlobalVariable *GV = &*I++; if (GV->getType()->getAddressSpace() == llvm::ADDRESS_SPACE_GENERIC && !llvm::isTexture(*GV) && !llvm::isSurface(*GV) && !llvm::isSampler(*GV) && !GV->getName().startswith("llvm.")) { @@ -117,7 +117,7 @@ bool GenericToNVVM::runOnModule(Module &M) { Value *Operand = II->getOperand(i); if (isa(Operand)) { II->setOperand( - i, remapConstant(&M, I, cast(Operand), Builder)); + i, remapConstant(&M, &*I, cast(Operand), Builder)); } } } @@ -132,10 +132,8 @@ bool GenericToNVVM::runOnModule(Module &M) { // Walk through the metadata section and update the debug information // associated with the global variables in the default address space. - for (Module::named_metadata_iterator I = M.named_metadata_begin(), - E = M.named_metadata_end(); - I != E; I++) { - remapNamedMDNode(VM, I); + for (NamedMDNode &I : M.named_metadata()) { + remapNamedMDNode(VM, &I); } // Walk through the global variable initializers, and replace any use of diff --git a/lib/Target/NVPTX/NVPTXISelLowering.cpp b/lib/Target/NVPTX/NVPTXISelLowering.cpp index d7324f2c1fe..766369631e1 100644 --- a/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -2071,10 +2071,9 @@ SDValue NVPTXTargetLowering::LowerFormalArguments( std::vector argTypes; std::vector theArgs; - for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); - I != E; ++I) { - theArgs.push_back(I); - argTypes.push_back(I->getType()); + for (const Argument &I : F->args()) { + theArgs.push_back(&I); + argTypes.push_back(I.getType()); } // argTypes.size() (or theArgs.size()) and Ins.size() need not match. // Ins.size() will be larger diff --git a/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp b/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp index 35298565e58..f770c2acaab 100644 --- a/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp +++ b/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp @@ -69,7 +69,7 @@ void convertMemCpyToLoop(Instruction *ConvertedInst, Value *SrcAddr, BasicBlock *LoopBB = BasicBlock::Create(Context, "loadstoreloop", &F, NewBB); OrigBB->getTerminator()->setSuccessor(0, LoopBB); - IRBuilder<> Builder(OrigBB, OrigBB->getTerminator()); + IRBuilder<> Builder(OrigBB->getTerminator()); // SrcAddr and DstAddr are expected to be pointer types, // so no check is made here. @@ -214,7 +214,7 @@ void convertMemSetToLoop(Instruction *ConvertedInst, Value *DstAddr, BasicBlock *LoopBB = BasicBlock::Create(Context, "loadstoreloop", &F, NewBB); OrigBB->getTerminator()->setSuccessor(0, LoopBB); - IRBuilder<> Builder(OrigBB, OrigBB->getTerminator()); + IRBuilder<> Builder(OrigBB->getTerminator()); // Cast pointer to the type of value getting stored unsigned dstAS = cast(DstAddr->getType())->getAddressSpace(); diff --git a/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp b/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp index 4cd96f0ce4e..6656077348a 100644 --- a/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp +++ b/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp @@ -173,8 +173,7 @@ void NVPTXLowerKernelArgs::markPointerAsGlobal(Value *Ptr) { InsertPt = Arg->getParent()->getEntryBlock().begin(); } else { // Insert right after Ptr if Ptr is an instruction. - InsertPt = cast(Ptr); - ++InsertPt; + InsertPt = ++cast(Ptr)->getIterator(); assert(InsertPt != InsertPt->getParent()->end() && "We don't call this function with Ptr being a terminator."); } @@ -182,9 +181,9 @@ void NVPTXLowerKernelArgs::markPointerAsGlobal(Value *Ptr) { Instruction *PtrInGlobal = new AddrSpaceCastInst( Ptr, PointerType::get(Ptr->getType()->getPointerElementType(), ADDRESS_SPACE_GLOBAL), - Ptr->getName(), InsertPt); + Ptr->getName(), &*InsertPt); Value *PtrInGeneric = new AddrSpaceCastInst(PtrInGlobal, Ptr->getType(), - Ptr->getName(), InsertPt); + Ptr->getName(), &*InsertPt); // Replace with PtrInGeneric all uses of Ptr except PtrInGlobal. Ptr->replaceAllUsesWith(PtrInGeneric); PtrInGlobal->setOperand(0, Ptr); diff --git a/lib/Target/NVPTX/NVPTXUtilities.cpp b/lib/Target/NVPTX/NVPTXUtilities.cpp index 7f6388f98ab..578b466568a 100644 --- a/lib/Target/NVPTX/NVPTXUtilities.cpp +++ b/lib/Target/NVPTX/NVPTXUtilities.cpp @@ -367,7 +367,7 @@ void llvm::dumpBlock(Value *v, char *blockName) { return; for (Function::iterator it = F->begin(), ie = F->end(); it != ie; ++it) { - BasicBlock *B = it; + BasicBlock *B = &*it; if (strcmp(B->getName().data(), blockName) == 0) { B->dump(); return; -- 2.34.1