From: Duncan P. N. Exon Smith Date: Thu, 8 Oct 2015 23:49:46 +0000 (+0000) Subject: IR: Remove implicit iterator conversions from lib/IR, NFC X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eac309550f259b7f78f1e69ea8e62fea493efd43;p=oota-llvm.git IR: Remove implicit iterator conversions from lib/IR, NFC Stop converting implicitly between iterators and pointers/references in lib/IR. For convenience, I've added a `getIterator()` accessor to `ilist_node` so that callers don't need to know how to spell the iterator class (i.e., they can use `X.getIterator()` instead of `Function::iterator(X)`). I'll eventually disallow these implicit conversions entirely, but there's a lot of code, so it doesn't make sense to do it all in one patch. One library or so at a time. Why? To root out cases of `getNextNode()` and `getPrevNode()` being used in iterator logic. The design of `ilist` makes that invalid when the current node could be at the back of the list, but it happens to "work" right now because of a bug where those functions never return `nullptr` if you're using a half-node sentinel. Before I can fix the function, I have to remove uses of it that rely on it misbehaving. (Maybe the function should just be deleted anyway? But I don't want deleting it -- potentially a huge project -- to block fixing ilist/iplist.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249782 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h index eb3f2cce929..f51d5d654d9 100644 --- a/include/llvm/ADT/ilist.h +++ b/include/llvm/ADT/ilist.h @@ -238,6 +238,8 @@ public: return *this; } + void reset(pointer NP) { NodePtr = NP; } + // Accessors... operator pointer() const { return NodePtr; @@ -469,7 +471,7 @@ public: this->setPrev(CurNode, New); this->addNodeToList(New); // Notify traits that we added a node... - return New; + return iterator(New); } iterator insertAfter(iterator where, NodeTy *New) { @@ -490,7 +492,7 @@ public: else Head = NextNode; this->setPrev(NextNode, PrevNode); - IT = NextNode; + IT.reset(NextNode); this->removeNodeFromList(Node); // Notify traits that we removed a node... // Set the next/prev pointers of the current node to null. This isn't @@ -569,7 +571,7 @@ private: this->setNext(Last, PosNext); this->setPrev(PosNext, Last); - this->transferNodesFromList(L2, First, PosNext); + this->transferNodesFromList(L2, iterator(First), iterator(PosNext)); // Now that everything is set, restore the pointers to the list sentinels. L2.setTail(L2Sentinel); diff --git a/include/llvm/ADT/ilist_node.h b/include/llvm/ADT/ilist_node.h index 85d7a908096..8f0538bcf6e 100644 --- a/include/llvm/ADT/ilist_node.h +++ b/include/llvm/ADT/ilist_node.h @@ -39,6 +39,8 @@ protected: template struct ilist_nextprev_traits; +template class ilist_iterator; + /// ilist_node - Base class that provides next/prev services for nodes /// that use ilist_nextprev_traits or ilist_default_traits. /// @@ -56,6 +58,15 @@ protected: ilist_node() : Next(nullptr) {} public: + ilist_iterator getIterator() { + // FIXME: Stop downcasting to create the iterator (potential UB). + return ilist_iterator(static_cast(this)); + } + ilist_iterator getIterator() const { + // FIXME: Stop downcasting to create the iterator (potential UB). + return ilist_iterator(static_cast(this)); + } + /// @name Adjacent Node Accessors /// @{ diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index ec7872c0660..a9e040b825c 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -75,7 +75,7 @@ public: /// inserted into a block. void ClearInsertionPoint() { BB = nullptr; - InsertPt = nullptr; + InsertPt.reset(nullptr); } BasicBlock *GetInsertBlock() const { return BB; } @@ -93,8 +93,8 @@ public: /// the specified instruction. void SetInsertPoint(Instruction *I) { BB = I->getParent(); - InsertPt = I; - assert(I != BB->end() && "Can't read debug loc from end()"); + InsertPt = I->getIterator(); + assert(InsertPt != BB->end() && "Can't read debug loc from end()"); SetCurrentDebugLocation(I->getDebugLoc()); } diff --git a/include/llvm/Support/GenericDomTree.h b/include/llvm/Support/GenericDomTree.h index a790d754d20..8751f272cd2 100644 --- a/include/llvm/Support/GenericDomTree.h +++ b/include/llvm/Support/GenericDomTree.h @@ -734,13 +734,13 @@ public: for (typename TraitsTy::nodes_iterator I = TraitsTy::nodes_begin(&F), E = TraitsTy::nodes_end(&F); I != E; ++I) { - if (TraitsTy::child_begin(I) == TraitsTy::child_end(I)) - addRoot(I); + if (TraitsTy::child_begin(&*I) == TraitsTy::child_end(&*I)) + addRoot(&*I); // Prepopulate maps so that we don't get iterator invalidation issues // later. - this->IDoms[I] = nullptr; - this->DomTreeNodes[I] = nullptr; + this->IDoms[&*I] = nullptr; + this->DomTreeNodes[&*I] = nullptr; } Calculate>(*this, F); diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index b4d7a660688..2b39f2273b3 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -817,7 +817,7 @@ void SlotTracker::processFunction() { for(Function::const_arg_iterator AI = TheFunction->arg_begin(), AE = TheFunction->arg_end(); AI != AE; ++AI) if (!AI->hasName()) - CreateFunctionSlot(AI); + CreateFunctionSlot(&*AI); ST_DEBUG("Inserting Instructions:\n"); @@ -2635,7 +2635,7 @@ void AssemblyWriter::printFunction(const Function *F) { Out << " {"; // Output all of the function's basic blocks. for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I) - printBasicBlock(I); + printBasicBlock(&*I); // Output the function's use-lists. printUseLists(F); diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index 6c9fdd6fcea..5ffe288efb6 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -362,7 +362,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Function *F = CI->getCalledFunction(); LLVMContext &C = CI->getContext(); IRBuilder<> Builder(C); - Builder.SetInsertPoint(CI->getParent(), CI); + Builder.SetInsertPoint(CI->getParent(), CI->getIterator()); assert(F && "Intrinsic call is not direct?"); @@ -388,7 +388,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Name == "llvm.x86.avx.movnt.ps.256" || Name == "llvm.x86.avx.movnt.pd.256") { IRBuilder<> Builder(C); - Builder.SetInsertPoint(CI->getParent(), CI); + Builder.SetInsertPoint(CI->getParent(), CI->getIterator()); Module *M = F->getParent(); SmallVector Elts; diff --git a/lib/IR/BasicBlock.cpp b/lib/IR/BasicBlock.cpp index 02e07eb5bb5..f61276fd436 100644 --- a/lib/IR/BasicBlock.cpp +++ b/lib/IR/BasicBlock.cpp @@ -56,7 +56,7 @@ void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) { assert(!Parent && "Already has a parent"); if (InsertBefore) - NewParent->getBasicBlockList().insert(InsertBefore, this); + NewParent->getBasicBlockList().insert(InsertBefore->getIterator(), this); else NewParent->getBasicBlockList().push_back(this); } @@ -91,26 +91,26 @@ void BasicBlock::setParent(Function *parent) { } void BasicBlock::removeFromParent() { - getParent()->getBasicBlockList().remove(this); + getParent()->getBasicBlockList().remove(getIterator()); } iplist::iterator BasicBlock::eraseFromParent() { - return getParent()->getBasicBlockList().erase(this); + return getParent()->getBasicBlockList().erase(getIterator()); } /// Unlink this basic block from its current function and /// insert it into the function that MovePos lives in, right before MovePos. void BasicBlock::moveBefore(BasicBlock *MovePos) { - MovePos->getParent()->getBasicBlockList().splice(MovePos, - getParent()->getBasicBlockList(), this); + MovePos->getParent()->getBasicBlockList().splice( + MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator()); } /// Unlink this basic block from its current function and /// insert it into the function that MovePos lives in, right after MovePos. void BasicBlock::moveAfter(BasicBlock *MovePos) { - Function::iterator I = MovePos; - MovePos->getParent()->getBasicBlockList().splice(++I, - getParent()->getBasicBlockList(), this); + MovePos->getParent()->getBasicBlockList().splice( + ++MovePos->getIterator(), getParent()->getBasicBlockList(), + getIterator()); } const Module *BasicBlock::getModule() const { @@ -196,7 +196,7 @@ BasicBlock::iterator BasicBlock::getFirstInsertionPt() { if (!FirstNonPHI) return end(); - iterator InsertPt = FirstNonPHI; + iterator InsertPt = FirstNonPHI->getIterator(); if (InsertPt->isEHPad()) ++InsertPt; return InsertPt; } diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 22413297796..7f39c8085a6 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -1533,7 +1533,7 @@ LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M) { Module::global_iterator I = Mod->global_begin(); if (I == Mod->global_end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M) { @@ -1541,23 +1541,23 @@ LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M) { Module::global_iterator I = Mod->global_end(); if (I == Mod->global_begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar) { GlobalVariable *GV = unwrap(GlobalVar); - Module::global_iterator I = GV; + Module::global_iterator I(GV); if (++I == GV->getParent()->global_end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar) { GlobalVariable *GV = unwrap(GlobalVar); - Module::global_iterator I = GV; + Module::global_iterator I(GV); if (I == GV->getParent()->global_begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } void LLVMDeleteGlobal(LLVMValueRef GlobalVar) { @@ -1666,7 +1666,7 @@ LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M) { Module::iterator I = Mod->begin(); if (I == Mod->end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M) { @@ -1674,23 +1674,23 @@ LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M) { Module::iterator I = Mod->end(); if (I == Mod->begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn) { Function *Func = unwrap(Fn); - Module::iterator I = Func; + Module::iterator I(Func); if (++I == Func->getParent()->end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn) { Function *Func = unwrap(Fn); - Module::iterator I = Func; + Module::iterator I(Func); if (I == Func->getParent()->begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } void LLVMDeleteFunction(LLVMValueRef Fn) { @@ -1785,14 +1785,14 @@ void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) { Function *Fn = unwrap(FnRef); for (Function::arg_iterator I = Fn->arg_begin(), E = Fn->arg_end(); I != E; I++) - *ParamRefs++ = wrap(I); + *ParamRefs++ = wrap(&*I); } LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) { Function::arg_iterator AI = unwrap(FnRef)->arg_begin(); while (index --> 0) AI++; - return wrap(AI); + return wrap(&*AI); } LLVMValueRef LLVMGetParamParent(LLVMValueRef V) { @@ -1804,7 +1804,7 @@ LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn) { Function::arg_iterator I = Func->arg_begin(); if (I == Func->arg_end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn) { @@ -1812,23 +1812,23 @@ LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn) { Function::arg_iterator I = Func->arg_end(); if (I == Func->arg_begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg) { Argument *A = unwrap(Arg); - Function::arg_iterator I = A; + Function::arg_iterator I(A); if (++I == A->getParent()->arg_end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) { Argument *A = unwrap(Arg); - Function::arg_iterator I = A; + Function::arg_iterator I(A); if (I == A->getParent()->arg_begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) { @@ -1886,7 +1886,7 @@ unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef) { void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs){ Function *Fn = unwrap(FnRef); for (Function::iterator I = Fn->begin(), E = Fn->end(); I != E; I++) - *BasicBlocksRefs++ = wrap(I); + *BasicBlocksRefs++ = wrap(&*I); } LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn) { @@ -1898,7 +1898,7 @@ LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn) { Function::iterator I = Func->begin(); if (I == Func->end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn) { @@ -1906,23 +1906,23 @@ LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn) { Function::iterator I = Func->end(); if (I == Func->begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB) { BasicBlock *Block = unwrap(BB); - Function::iterator I = Block; + Function::iterator I(Block); if (++I == Block->getParent()->end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB) { BasicBlock *Block = unwrap(BB); - Function::iterator I = Block; + Function::iterator I(Block); if (I == Block->getParent()->begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, @@ -1974,7 +1974,7 @@ LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB) { BasicBlock::iterator I = Block->begin(); if (I == Block->end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB) { @@ -1982,23 +1982,23 @@ LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB) { BasicBlock::iterator I = Block->end(); if (I == Block->begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst) { Instruction *Instr = unwrap(Inst); - BasicBlock::iterator I = Instr; + BasicBlock::iterator I(Instr); if (++I == Instr->getParent()->end()) return nullptr; - return wrap(I); + return wrap(&*I); } LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst) { Instruction *Instr = unwrap(Inst); - BasicBlock::iterator I = Instr; + BasicBlock::iterator I(Instr); if (I == Instr->getParent()->begin()) return nullptr; - return wrap(--I); + return wrap(&*--I); } void LLVMInstructionEraseFromParent(LLVMValueRef Inst) { @@ -2166,12 +2166,12 @@ void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr) { BasicBlock *BB = unwrap(Block); Instruction *I = Instr? unwrap(Instr) : (Instruction*) BB->end(); - unwrap(Builder)->SetInsertPoint(BB, I); + unwrap(Builder)->SetInsertPoint(BB, I->getIterator()); } void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr) { Instruction *I = unwrap(Instr); - unwrap(Builder)->SetInsertPoint(I->getParent(), I); + unwrap(Builder)->SetInsertPoint(I->getParent(), I->getIterator()); } void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block) { diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 55e46b36a14..b22ba53645d 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -336,7 +336,7 @@ bool llvm::StripDebugInfo(Module &M) { for (Module::named_metadata_iterator NMI = M.named_metadata_begin(), NME = M.named_metadata_end(); NMI != NME;) { - NamedMDNode *NMD = NMI; + NamedMDNode *NMD = &*NMI; ++NMI; if (NMD->getName().startswith("llvm.dbg.")) { NMD->eraseFromParent(); diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index 3935a33d170..3a1c7a4ca36 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -235,11 +235,11 @@ Type *Function::getReturnType() const { } void Function::removeFromParent() { - getParent()->getFunctionList().remove(this); + getParent()->getFunctionList().remove(getIterator()); } void Function::eraseFromParent() { - getParent()->getFunctionList().erase(this); + getParent()->getFunctionList().erase(getIterator()); } //===----------------------------------------------------------------------===// diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index 11ece2ed1b1..8fde4b8e9d7 100644 --- a/lib/IR/Globals.cpp +++ b/lib/IR/Globals.cpp @@ -178,7 +178,7 @@ GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant, } if (Before) - Before->getParent()->getGlobalList().insert(Before, this); + Before->getParent()->getGlobalList().insert(Before->getIterator(), this); else M.getGlobalList().push_back(this); } @@ -188,11 +188,11 @@ void GlobalVariable::setParent(Module *parent) { } void GlobalVariable::removeFromParent() { - getParent()->getGlobalList().remove(this); + getParent()->getGlobalList().remove(getIterator()); } void GlobalVariable::eraseFromParent() { - getParent()->getGlobalList().erase(this); + getParent()->getGlobalList().erase(getIterator()); } void GlobalVariable::setInitializer(Constant *InitVal) { @@ -276,11 +276,11 @@ void GlobalAlias::setParent(Module *parent) { } void GlobalAlias::removeFromParent() { - getParent()->getAliasList().remove(this); + getParent()->getAliasList().remove(getIterator()); } void GlobalAlias::eraseFromParent() { - getParent()->getAliasList().erase(this); + getParent()->getAliasList().erase(getIterator()); } void GlobalAlias::setAliasee(Constant *Aliasee) { diff --git a/lib/IR/Instruction.cpp b/lib/IR/Instruction.cpp index 91ac83c10d4..b5a30a4969b 100644 --- a/lib/IR/Instruction.cpp +++ b/lib/IR/Instruction.cpp @@ -28,7 +28,7 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps, if (InsertBefore) { BasicBlock *BB = InsertBefore->getParent(); assert(BB && "Instruction to insert before is not in a basic block!"); - BB->getInstList().insert(InsertBefore, this); + BB->getInstList().insert(InsertBefore->getIterator(), this); } } @@ -64,31 +64,32 @@ Module *Instruction::getModule() { void Instruction::removeFromParent() { - getParent()->getInstList().remove(this); + getParent()->getInstList().remove(getIterator()); } iplist::iterator Instruction::eraseFromParent() { - return getParent()->getInstList().erase(this); + return getParent()->getInstList().erase(getIterator()); } /// insertBefore - Insert an unlinked instructions into a basic block /// immediately before the specified instruction. void Instruction::insertBefore(Instruction *InsertPos) { - InsertPos->getParent()->getInstList().insert(InsertPos, this); + InsertPos->getParent()->getInstList().insert(InsertPos->getIterator(), this); } /// insertAfter - Insert an unlinked instructions into a basic block /// immediately after the specified instruction. void Instruction::insertAfter(Instruction *InsertPos) { - InsertPos->getParent()->getInstList().insertAfter(InsertPos, this); + InsertPos->getParent()->getInstList().insertAfter(InsertPos->getIterator(), + this); } /// moveBefore - Unlink this instruction from its current basic block and /// insert it into the basic block that MovePos lives in, right before /// MovePos. void Instruction::moveBefore(Instruction *MovePos) { - MovePos->getParent()->getInstList().splice(MovePos,getParent()->getInstList(), - this); + MovePos->getParent()->getInstList().splice( + MovePos->getIterator(), getParent()->getInstList(), getIterator()); } /// Set or clear the unsafe-algebra flag on this instruction, which must be an diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index 21dfb0912fc..2b9adad44ba 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -277,7 +277,7 @@ NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { /// delete it. void Module::eraseNamedMetadata(NamedMDNode *NMD) { static_cast *>(NamedMDSymTab)->erase(NMD->getName()); - NamedMDList.erase(NMD); + NamedMDList.erase(NMD->getIterator()); } bool Module::isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB) { diff --git a/lib/IR/SymbolTableListTraitsImpl.h b/lib/IR/SymbolTableListTraitsImpl.h index e7fa8ba58f4..50573d8d688 100644 --- a/lib/IR/SymbolTableListTraitsImpl.h +++ b/lib/IR/SymbolTableListTraitsImpl.h @@ -55,7 +55,7 @@ void SymbolTableListTraits::setSymTabObject(TPtr *Dest, // Add all of the items to the new symtab. for (auto I = ItemList.begin(); I != ItemList.end(); ++I) if (I->hasName()) - NewST->reinsertValue(I); + NewST->reinsertValue(&*I); } } diff --git a/lib/IR/TypeFinder.cpp b/lib/IR/TypeFinder.cpp index 7accc5bef53..2ea0550ba45 100644 --- a/lib/IR/TypeFinder.cpp +++ b/lib/IR/TypeFinder.cpp @@ -56,7 +56,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) { // First incorporate the arguments. for (Function::const_arg_iterator AI = FI->arg_begin(), AE = FI->arg_end(); AI != AE; ++AI) - incorporateValue(AI); + incorporateValue(&*AI); for (Function::const_iterator BB = FI->begin(), E = FI->end(); BB != E;++BB) @@ -85,7 +85,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) { for (Module::const_named_metadata_iterator I = M.named_metadata_begin(), E = M.named_metadata_end(); I != E; ++I) { - const NamedMDNode *NMD = I; + const NamedMDNode *NMD = &*I; for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) incorporateMDNode(NMD->getOperand(i)); } diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 7b07bcea560..0207fe8150b 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -92,6 +92,10 @@ struct VerifierSupport { : OS(OS), M(nullptr), Broken(false) {} private: + template void Write(const ilist_iterator &I) { + Write(&*I); + } + void Write(const Value *V) { if (!V) return;