[llvm] r250187 - IPO: Remove implicit ilist iterator conversions, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 10:51:05 PDT 2015
Author: dexonsmith
Date: Tue Oct 13 12:51:03 2015
New Revision: 250187
URL: http://llvm.org/viewvc/llvm-project?rev=250187&view=rev
Log:
IPO: Remove implicit ilist iterator conversions, NFC
Modified:
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/Transforms/IPO/Internalize.cpp
llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp
llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Tue Oct 13 12:51:03 2015
@@ -223,9 +223,9 @@ CallGraphNode *ArgPromotion::PromoteArgu
// First check: see if there are any pointer arguments! If not, quick exit.
SmallVector<Argument*, 16> PointerArgs;
- for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
- if (I->getType()->isPointerTy())
- PointerArgs.push_back(I);
+ for (Argument &I : F->args())
+ if (I.getType()->isPointerTy())
+ PointerArgs.push_back(&I);
if (PointerArgs.empty()) return nullptr;
// Second check: make sure that all callers are direct callers. We can't
@@ -468,12 +468,11 @@ bool ArgPromotion::isSafeToPromoteArgume
// First, iterate the entry block and mark loads of (geps of) arguments as
// safe.
- BasicBlock *EntryBlock = Arg->getParent()->begin();
+ BasicBlock &EntryBlock = Arg->getParent()->front();
// Declare this here so we can reuse it
IndicesVector Indices;
- for (BasicBlock::iterator I = EntryBlock->begin(), E = EntryBlock->end();
- I != E; ++I)
- if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
+ for (Instruction &I : EntryBlock)
+ if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
Value *V = LI->getPointerOperand();
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V)) {
V = GEP->getPointerOperand();
@@ -648,13 +647,13 @@ CallGraphNode *ArgPromotion::DoPromotion
unsigned ArgIndex = 1;
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
++I, ++ArgIndex) {
- if (ByValArgsToTransform.count(I)) {
+ if (ByValArgsToTransform.count(&*I)) {
// Simple byval argument? Just add all the struct element types.
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
StructType *STy = cast<StructType>(AgTy);
Params.insert(Params.end(), STy->element_begin(), STy->element_end());
++NumByValArgsPromoted;
- } else if (!ArgsToPromote.count(I)) {
+ } else if (!ArgsToPromote.count(&*I)) {
// Unchanged argument
Params.push_back(I->getType());
AttributeSet attrs = PAL.getParamAttributes(ArgIndex);
@@ -672,7 +671,7 @@ CallGraphNode *ArgPromotion::DoPromotion
// In this table, we will track which indices are loaded from the argument
// (where direct loads are tracked as no indices).
- ScalarizeTable &ArgIndices = ScalarizedElements[I];
+ ScalarizeTable &ArgIndices = ScalarizedElements[&*I];
for (User *U : I->users()) {
Instruction *UI = cast<Instruction>(U);
Type *SrcTy;
@@ -698,7 +697,7 @@ CallGraphNode *ArgPromotion::DoPromotion
else
// Take any load, we will use it only to update Alias Analysis
OrigLoad = cast<LoadInst>(UI->user_back());
- OriginalLoads[std::make_pair(I, Indices)] = OrigLoad;
+ OriginalLoads[std::make_pair(&*I, Indices)] = OrigLoad;
}
// Add a parameter to the function for each element passed in.
@@ -751,7 +750,7 @@ CallGraphNode *ArgPromotion::DoPromotion
NF->setAttributes(AttributeSet::get(F->getContext(), AttributesVec));
AttributesVec.clear();
- F->getParent()->getFunctionList().insert(F, NF);
+ F->getParent()->getFunctionList().insert(F->getIterator(), NF);
NF->takeName(F);
// Get the callgraph information that we need to update to reflect our
@@ -782,7 +781,7 @@ CallGraphNode *ArgPromotion::DoPromotion
ArgIndex = 1;
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
I != E; ++I, ++AI, ++ArgIndex)
- if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) {
+ if (!ArgsToPromote.count(&*I) && !ByValArgsToTransform.count(&*I)) {
Args.push_back(*AI); // Unmodified argument
if (CallPAL.hasAttributes(ArgIndex)) {
@@ -790,7 +789,7 @@ CallGraphNode *ArgPromotion::DoPromotion
AttributesVec.
push_back(AttributeSet::get(F->getContext(), Args.size(), B));
}
- } else if (ByValArgsToTransform.count(I)) {
+ } else if (ByValArgsToTransform.count(&*I)) {
// Emit a GEP and load for each element of the struct.
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
StructType *STy = cast<StructType>(AgTy);
@@ -805,14 +804,14 @@ CallGraphNode *ArgPromotion::DoPromotion
}
} else if (!I->use_empty()) {
// Non-dead argument: insert GEPs and loads as appropriate.
- ScalarizeTable &ArgIndices = ScalarizedElements[I];
+ ScalarizeTable &ArgIndices = ScalarizedElements[&*I];
// Store the Value* version of the indices in here, but declare it now
// for reuse.
std::vector<Value*> Ops;
for (ScalarizeTable::iterator SI = ArgIndices.begin(),
E = ArgIndices.end(); SI != E; ++SI) {
Value *V = *AI;
- LoadInst *OrigLoad = OriginalLoads[std::make_pair(I, SI->second)];
+ LoadInst *OrigLoad = OriginalLoads[std::make_pair(&*I, SI->second)];
if (!SI->second.empty()) {
Ops.reserve(SI->second.size());
Type *ElTy = V->getType();
@@ -904,19 +903,19 @@ CallGraphNode *ArgPromotion::DoPromotion
//
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(),
I2 = NF->arg_begin(); I != E; ++I) {
- if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) {
+ if (!ArgsToPromote.count(&*I) && !ByValArgsToTransform.count(&*I)) {
// If this is an unmodified argument, move the name and users over to the
// new version.
- I->replaceAllUsesWith(I2);
- I2->takeName(I);
+ I->replaceAllUsesWith(&*I2);
+ I2->takeName(&*I);
++I2;
continue;
}
- if (ByValArgsToTransform.count(I)) {
+ if (ByValArgsToTransform.count(&*I)) {
// In the callee, we create an alloca, and store each of the new incoming
// arguments into the alloca.
- Instruction *InsertPt = NF->begin()->begin();
+ Instruction *InsertPt = &NF->begin()->front();
// Just add all the struct element types.
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
@@ -931,12 +930,12 @@ CallGraphNode *ArgPromotion::DoPromotion
AgTy, TheAlloca, Idxs, TheAlloca->getName() + "." + Twine(i),
InsertPt);
I2->setName(I->getName()+"."+Twine(i));
- new StoreInst(I2++, Idx, InsertPt);
+ new StoreInst(&*I2++, Idx, InsertPt);
}
// Anything that used the arg should now use the alloca.
I->replaceAllUsesWith(TheAlloca);
- TheAlloca->takeName(I);
+ TheAlloca->takeName(&*I);
// If the alloca is used in a call, we must clear the tail flag since
// the callee now uses an alloca from the caller.
@@ -955,14 +954,14 @@ CallGraphNode *ArgPromotion::DoPromotion
// Otherwise, if we promoted this argument, then all users are load
// instructions (or GEPs with only load users), and all loads should be
// using the new argument that we added.
- ScalarizeTable &ArgIndices = ScalarizedElements[I];
+ ScalarizeTable &ArgIndices = ScalarizedElements[&*I];
while (!I->use_empty()) {
if (LoadInst *LI = dyn_cast<LoadInst>(I->user_back())) {
assert(ArgIndices.begin()->second.empty() &&
"Load element should sort to front!");
I2->setName(I->getName()+".val");
- LI->replaceAllUsesWith(I2);
+ LI->replaceAllUsesWith(&*I2);
LI->eraseFromParent();
DEBUG(dbgs() << "*** Promoted load of argument '" << I->getName()
<< "' in function '" << F->getName() << "'\n");
@@ -998,7 +997,7 @@ CallGraphNode *ArgPromotion::DoPromotion
// the argument specified by ArgNo.
while (!GEP->use_empty()) {
LoadInst *L = cast<LoadInst>(GEP->user_back());
- L->replaceAllUsesWith(TheArg);
+ L->replaceAllUsesWith(&*TheArg);
L->eraseFromParent();
}
GEP->eraseFromParent();
Modified: llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp Tue Oct 13 12:51:03 2015
@@ -119,7 +119,7 @@ bool ConstantMerge::runOnModule(Module &
// First: Find the canonical constants others will be merged with.
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
GVI != E; ) {
- GlobalVariable *GV = GVI++;
+ GlobalVariable *GV = &*GVI++;
// If this GV is dead, remove it.
GV->removeDeadConstantUsers();
@@ -160,7 +160,7 @@ bool ConstantMerge::runOnModule(Module &
// invalidating the Constant* pointers in CMap.
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
GVI != E; ) {
- GlobalVariable *GV = GVI++;
+ GlobalVariable *GV = &*GVI++;
// Only process constants with initializers in the default address space.
if (!GV->isConstant() || !GV->hasDefinitiveInitializer() ||
Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Tue Oct 13 12:51:03 2015
@@ -237,7 +237,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, Fn.getLinkage());
NF->copyAttributesFrom(&Fn);
- Fn.getParent()->getFunctionList().insert(&Fn, NF);
+ Fn.getParent()->getFunctionList().insert(Fn.getIterator(), NF);
NF->takeName(&Fn);
// Loop over all of the callers of the function, transforming the call sites
@@ -304,8 +304,8 @@ bool DAE::DeleteDeadVarargs(Function &Fn
for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end(),
I2 = NF->arg_begin(); I != E; ++I, ++I2) {
// Move the name and users over to the new version.
- I->replaceAllUsesWith(I2);
- I2->takeName(I);
+ I->replaceAllUsesWith(&*I2);
+ I2->takeName(&*I);
}
// Patch the pointer to LLVM function in debug info descriptor.
@@ -363,12 +363,9 @@ bool DAE::RemoveDeadArgumentsFromCallers
return false;
SmallVector<unsigned, 8> UnusedArgs;
- for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
- I != E; ++I) {
- Argument *Arg = I;
-
- if (Arg->use_empty() && !Arg->hasByValOrInAllocaAttr())
- UnusedArgs.push_back(Arg->getArgNo());
+ for (Argument &Arg : Fn.args()) {
+ if (Arg.use_empty() && !Arg.hasByValOrInAllocaAttr())
+ UnusedArgs.push_back(Arg.getArgNo());
}
if (UnusedArgs.empty())
@@ -670,7 +667,7 @@ void DAE::SurveyFunction(const Function
} else {
// See what the effect of this use is (recording any uses that cause
// MaybeLive in MaybeLiveArgUses).
- Result = SurveyUses(AI, MaybeLiveArgUses);
+ Result = SurveyUses(&*AI, MaybeLiveArgUses);
}
// Mark the result.
@@ -900,7 +897,7 @@ bool DAE::RemoveDeadStuffFromFunction(Fu
NF->setAttributes(NewPAL);
// Insert the new function before the old function, so we won't be processing
// it again.
- F->getParent()->getFunctionList().insert(F, NF);
+ F->getParent()->getFunctionList().insert(F->getIterator(), NF);
NF->takeName(F);
// Loop over all of the callers of the function, transforming the call sites
@@ -999,7 +996,7 @@ bool DAE::RemoveDeadStuffFromFunction(Fu
Instruction *InsertPt = Call;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
BasicBlock *NewEdge = SplitEdge(New->getParent(), II->getNormalDest());
- InsertPt = NewEdge->getFirstInsertionPt();
+ InsertPt = &*NewEdge->getFirstInsertionPt();
}
// We used to return a struct or array. Instead of doing smart stuff
@@ -1047,8 +1044,8 @@ bool DAE::RemoveDeadStuffFromFunction(Fu
if (ArgAlive[i]) {
// If this is a live argument, move the name and users over to the new
// version.
- I->replaceAllUsesWith(I2);
- I2->takeName(I);
+ I->replaceAllUsesWith(&*I2);
+ I2->takeName(&*I);
++I2;
} else {
// If this argument is dead, replace any uses of it with null constants
@@ -1140,7 +1137,7 @@ bool DAE::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
// Increment now, because the function will probably get removed (ie.
// replaced by a new one).
- Function *F = I++;
+ Function *F = &*I++;
Changed |= RemoveDeadStuffFromFunction(F);
}
Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Tue Oct 13 12:51:03 2015
@@ -83,7 +83,7 @@ namespace {
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
bool Delete =
- deleteStuff == (bool)Named.count(I) && !I->isDeclaration();
+ deleteStuff == (bool)Named.count(&*I) && !I->isDeclaration();
if (!Delete) {
if (I->hasAvailableExternallyLinkage())
continue;
@@ -103,7 +103,7 @@ namespace {
// Visit the Functions.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
bool Delete =
- deleteStuff == (bool)Named.count(I) && !I->isDeclaration();
+ deleteStuff == (bool)Named.count(&*I) && !I->isDeclaration();
if (!Delete) {
if (I->hasAvailableExternallyLinkage())
continue;
@@ -124,7 +124,7 @@ namespace {
Module::alias_iterator CurI = I;
++I;
- bool Delete = deleteStuff == (bool)Named.count(CurI);
+ bool Delete = deleteStuff == (bool)Named.count(&*CurI);
makeVisible(*CurI, Delete);
if (Delete) {
@@ -143,7 +143,7 @@ namespace {
}
CurI->replaceAllUsesWith(Declaration);
- delete CurI;
+ delete &*CurI;
}
}
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Tue Oct 13 12:51:03 2015
@@ -347,7 +347,7 @@ struct ArgumentUsesTracker : public Capt
return true;
}
if (PI == U) {
- Uses.push_back(AI);
+ Uses.push_back(&*AI);
Found = true;
break;
}
@@ -466,7 +466,7 @@ determinePointerReadAttrs(Argument *A,
return Attribute::None;
}
Captures &= !CS.doesNotCapture(A - B);
- if (SCCNodes.count(AI))
+ if (SCCNodes.count(&*AI))
continue;
if (!CS.onlyReadsMemory() && !CS.onlyReadsMemory(A - B))
return Attribute::None;
@@ -551,7 +551,7 @@ bool FunctionAttrs::AddArgumentAttrs(con
bool HasNonLocalUses = false;
if (!A->hasNoCaptureAttr()) {
ArgumentUsesTracker Tracker(SCCNodes);
- PointerMayBeCaptured(A, &Tracker);
+ PointerMayBeCaptured(&*A, &Tracker);
if (!Tracker.Captured) {
if (Tracker.Uses.empty()) {
// If it's trivially not captured, mark it nocapture now.
@@ -563,7 +563,7 @@ bool FunctionAttrs::AddArgumentAttrs(con
// If it's not trivially captured and not trivially not captured,
// then it must be calling into another function in our SCC. Save
// its particulars for Argument-SCC analysis later.
- ArgumentGraphNode *Node = AG[A];
+ ArgumentGraphNode *Node = AG[&*A];
for (SmallVectorImpl<Argument *>::iterator
UI = Tracker.Uses.begin(),
UE = Tracker.Uses.end();
@@ -582,8 +582,8 @@ bool FunctionAttrs::AddArgumentAttrs(con
// will be dependent on the iteration order through the functions in the
// SCC.
SmallPtrSet<Argument *, 8> Self;
- Self.insert(A);
- Attribute::AttrKind R = determinePointerReadAttrs(A, Self);
+ Self.insert(&*A);
+ Attribute::AttrKind R = determinePointerReadAttrs(&*A, Self);
if (R != Attribute::None) {
AttrBuilder B;
B.addAttribute(R);
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Oct 13 12:51:03 2015
@@ -497,7 +497,7 @@ static GlobalVariable *SRAGlobal(GlobalV
In, GV->getName()+"."+Twine(i),
GV->getThreadLocalMode(),
GV->getType()->getAddressSpace());
- Globals.insert(GV, NGV);
+ Globals.insert(GV->getIterator(), NGV);
NewGlobals.push_back(NGV);
// Calculate the known alignment of the field. If the original aggregate
@@ -530,7 +530,7 @@ static GlobalVariable *SRAGlobal(GlobalV
In, GV->getName()+"."+Twine(i),
GV->getThreadLocalMode(),
GV->getType()->getAddressSpace());
- Globals.insert(GV, NGV);
+ Globals.insert(GV->getIterator(), NGV);
NewGlobals.push_back(NGV);
// Calculate the known alignment of the field. If the original aggregate
@@ -935,7 +935,7 @@ OptimizeGlobalAddressOfMalloc(GlobalVari
cast<StoreInst>(InitBool->user_back())->eraseFromParent();
delete InitBool;
} else
- GV->getParent()->getGlobalList().insert(GV, InitBool);
+ GV->getParent()->getGlobalList().insert(GV->getIterator(), InitBool);
// Now the GV is dead, nuke it and the malloc..
GV->eraseFromParent();
@@ -1336,7 +1336,8 @@ static GlobalVariable *PerformHeapAllocS
// Split the basic block at the old malloc.
BasicBlock *OrigBB = CI->getParent();
- BasicBlock *ContBB = OrigBB->splitBasicBlock(CI, "malloc_cont");
+ BasicBlock *ContBB =
+ OrigBB->splitBasicBlock(CI->getIterator(), "malloc_cont");
// Create the block to check the first condition. Put all these blocks at the
// end of the function as they are unlikely to be executed.
@@ -1499,7 +1500,8 @@ static bool TryToOptimizeStoreOfMallocTo
// (2048 bytes currently), as we don't want to introduce a 16M global or
// something.
if (NElements->getZExtValue() * DL.getTypeAllocSize(AllocTy) < 2048) {
- GVI = OptimizeGlobalAddressOfMalloc(GV, CI, AllocTy, NElements, DL, TLI);
+ GVI = OptimizeGlobalAddressOfMalloc(GV, CI, AllocTy, NElements, DL, TLI)
+ ->getIterator();
return true;
}
@@ -1545,7 +1547,8 @@ static bool TryToOptimizeStoreOfMallocTo
}
GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, DL, TLI, true),
- DL, TLI);
+ DL, TLI)
+ ->getIterator();
return true;
}
@@ -1620,7 +1623,7 @@ static bool TryToShrinkGlobalToBoolean(G
GV->getName()+".b",
GV->getThreadLocalMode(),
GV->getType()->getAddressSpace());
- GV->getParent()->getGlobalList().insert(GV, NewGV);
+ GV->getParent()->getGlobalList().insert(GV->getIterator(), NewGV);
Constant *InitVal = GV->getInitializer();
assert(InitVal->getType() != Type::getInt1Ty(GV->getContext()) &&
@@ -1801,7 +1804,7 @@ bool GlobalOpt::ProcessInternalGlobal(Gl
} else if (!GV->getInitializer()->getType()->isSingleValueType()) {
const DataLayout &DL = GV->getParent()->getDataLayout();
if (GlobalVariable *FirstNewGV = SRAGlobal(GV, DL)) {
- GVI = FirstNewGV; // Don't skip the newly produced globals!
+ GVI = FirstNewGV->getIterator(); // Don't skip the newly produced globals!
return true;
}
} else if (GS.StoredType == GlobalStatus::StoredOnce && GS.StoredOnceValue) {
@@ -1823,7 +1826,7 @@ bool GlobalOpt::ProcessInternalGlobal(Gl
GV->eraseFromParent();
++NumDeleted;
} else {
- GVI = GV;
+ GVI = GV->getIterator();
}
++NumSubstitute;
return true;
@@ -1898,7 +1901,7 @@ bool GlobalOpt::OptimizeFunctions(Module
bool Changed = false;
// Optimize functions.
for (Module::iterator FI = M.begin(), E = M.end(); FI != E; ) {
- Function *F = FI++;
+ Function *F = &*FI++;
// Functions without names cannot be referenced outside this module.
if (!F->hasName() && !F->isDeclaration() && !F->hasLocalLinkage())
F->setLinkage(GlobalValue::InternalLinkage);
@@ -1940,7 +1943,7 @@ bool GlobalOpt::OptimizeGlobalVars(Modul
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
GVI != E; ) {
- GlobalVariable *GV = GVI++;
+ GlobalVariable *GV = &*GVI++;
// Global variables without names cannot be referenced outside this module.
if (!GV->hasName() && !GV->isDeclaration() && !GV->hasLocalLinkage())
GV->setLinkage(GlobalValue::InternalLinkage);
@@ -2438,7 +2441,7 @@ bool Evaluator::EvaluateBlock(BasicBlock
InstResult = AllocaTmps.back().get();
DEBUG(dbgs() << "Found an alloca. Result: " << *InstResult << "\n");
} else if (isa<CallInst>(CurInst) || isa<InvokeInst>(CurInst)) {
- CallSite CS(CurInst);
+ CallSite CS(&*CurInst);
// Debug info can safely be ignored here.
if (isa<DbgInfoIntrinsic>(CS.getInstruction())) {
@@ -2604,7 +2607,7 @@ bool Evaluator::EvaluateBlock(BasicBlock
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(InstResult))
InstResult = ConstantFoldConstantExpression(CE, DL, TLI);
- setVal(CurInst, InstResult);
+ setVal(&*CurInst, InstResult);
}
// If we just processed an invoke, we finished evaluating the block.
@@ -2635,7 +2638,7 @@ bool Evaluator::EvaluateFunction(Functio
unsigned ArgNo = 0;
for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E;
++AI, ++ArgNo)
- setVal(AI, ActualArgs[ArgNo]);
+ setVal(&*AI, ActualArgs[ArgNo]);
// ExecutedBlocks - We only handle non-looping, non-recursive code. As such,
// we can only evaluate any one basic block at most once. This set keeps
@@ -2643,7 +2646,7 @@ bool Evaluator::EvaluateFunction(Functio
SmallPtrSet<BasicBlock*, 32> ExecutedBlocks;
// CurBB - The current basic block we're evaluating.
- BasicBlock *CurBB = F->begin();
+ BasicBlock *CurBB = &F->front();
BasicBlock::iterator CurInst = CurBB->begin();
@@ -2894,15 +2897,15 @@ bool GlobalOpt::OptimizeGlobalAliases(Mo
if (RenameTarget) {
// Give the aliasee the name, linkage and other attributes of the alias.
- Target->takeName(J);
+ Target->takeName(&*J);
Target->setLinkage(J->getLinkage());
Target->setVisibility(J->getVisibility());
Target->setDLLStorageClass(J->getDLLStorageClass());
- if (Used.usedErase(J))
+ if (Used.usedErase(&*J))
Used.usedInsert(Target);
- if (Used.compilerUsedErase(J))
+ if (Used.compilerUsedErase(&*J))
Used.compilerUsedInsert(Target);
} else if (mayHaveOtherReferences(*J, Used))
continue;
Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Tue Oct 13 12:51:03 2015
@@ -202,16 +202,16 @@ bool InternalizePass::runOnModule(Module
}
// Mark all functions not in the api as internal.
- for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
- if (!maybeInternalize(*I, ExternalComdats))
+ for (Function &I : M) {
+ if (!maybeInternalize(I, ExternalComdats))
continue;
if (ExternalNode)
// Remove a callgraph edge from the external node to this function.
- ExternalNode->removeOneAbstractEdgeTo((*CG)[I]);
+ ExternalNode->removeOneAbstractEdgeTo((*CG)[&I]);
++NumFunctions;
- DEBUG(dbgs() << "Internalizing func " << I->getName() << "\n");
+ DEBUG(dbgs() << "Internalizing func " << I.getName() << "\n");
}
// Never internalize the llvm.used symbol. It is used to implement
Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp Tue Oct 13 12:51:03 2015
@@ -259,7 +259,7 @@ bool BlockExtractorPass::runOnModule(Mod
// Figure out which index the basic block is in its function.
Function::iterator BBI = MF->begin();
std::advance(BBI, std::distance(F->begin(), Function::iterator(BB)));
- TranslatedBlocksToNotExtract.insert(BBI);
+ TranslatedBlocksToNotExtract.insert(&*BBI);
}
while (!BlocksToNotExtractByName.empty()) {
@@ -278,7 +278,7 @@ bool BlockExtractorPass::runOnModule(Mod
BasicBlock &BB = *BI;
if (BB.getName() != BlockName) continue;
- TranslatedBlocksToNotExtract.insert(BI);
+ TranslatedBlocksToNotExtract.insert(&*BI);
}
}
@@ -291,8 +291,8 @@ bool BlockExtractorPass::runOnModule(Mod
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
SplitLandingPadPreds(&*F);
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
- if (!TranslatedBlocksToNotExtract.count(BB))
- BlocksToExtract.push_back(BB);
+ if (!TranslatedBlocksToNotExtract.count(&*BB))
+ BlocksToExtract.push_back(&*BB);
}
for (unsigned i = 0, e = BlocksToExtract.size(); i != e; ++i) {
Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Tue Oct 13 12:51:03 2015
@@ -1121,7 +1121,7 @@ int FunctionComparator::cmpBasicBlocks(c
BasicBlock::const_iterator InstR = BBR->begin(), InstRE = BBR->end();
do {
- if (int Res = cmpValues(InstL, InstR))
+ if (int Res = cmpValues(&*InstL, &*InstR))
return Res;
const GetElementPtrInst *GEPL = dyn_cast<GetElementPtrInst>(InstL);
@@ -1139,7 +1139,7 @@ int FunctionComparator::cmpBasicBlocks(c
if (int Res = cmpGEPs(GEPL, GEPR))
return Res;
} else {
- if (int Res = cmpOperations(InstL, InstR))
+ if (int Res = cmpOperations(&*InstL, &*InstR))
return Res;
assert(InstL->getNumOperands() == InstR->getNumOperands());
@@ -1207,7 +1207,7 @@ int FunctionComparator::compare() {
ArgRI = FnR->arg_begin(),
ArgLE = FnL->arg_end();
ArgLI != ArgLE; ++ArgLI, ++ArgRI) {
- if (cmpValues(ArgLI, ArgRI) != 0)
+ if (cmpValues(&*ArgLI, &*ArgRI) != 0)
llvm_unreachable("Arguments repeat!");
}
@@ -1658,9 +1658,8 @@ void MergeFunctions::writeThunk(Function
SmallVector<Value *, 16> Args;
unsigned i = 0;
FunctionType *FFTy = F->getFunctionType();
- for (Function::arg_iterator AI = NewG->arg_begin(), AE = NewG->arg_end();
- AI != AE; ++AI) {
- Args.push_back(createCast(Builder, (Value*)AI, FFTy->getParamType(i)));
+ for (Argument & AI : NewG->args()) {
+ Args.push_back(createCast(Builder, &AI, FFTy->getParamType(i)));
++i;
}
Modified: llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp Tue Oct 13 12:51:03 2015
@@ -50,7 +50,7 @@ ModulePass* llvm::createPartialInliningP
Function* PartialInliner::unswitchFunction(Function* F) {
// First, verify that this function is an unswitching candidate...
- BasicBlock* entryBlock = F->begin();
+ BasicBlock *entryBlock = &F->front();
BranchInst *BR = dyn_cast<BranchInst>(entryBlock->getTerminator());
if (!BR || BR->isUnconditional())
return nullptr;
@@ -89,18 +89,18 @@ Function* PartialInliner::unswitchFuncti
// of which will go outside.
BasicBlock* preReturn = newReturnBlock;
newReturnBlock = newReturnBlock->splitBasicBlock(
- newReturnBlock->getFirstNonPHI());
+ newReturnBlock->getFirstNonPHI()->getIterator());
BasicBlock::iterator I = preReturn->begin();
- BasicBlock::iterator Ins = newReturnBlock->begin();
+ Instruction *Ins = &newReturnBlock->front();
while (I != preReturn->end()) {
PHINode* OldPhi = dyn_cast<PHINode>(I);
if (!OldPhi) break;
-
- PHINode* retPhi = PHINode::Create(OldPhi->getType(), 2, "", Ins);
+
+ PHINode *retPhi = PHINode::Create(OldPhi->getType(), 2, "", Ins);
OldPhi->replaceAllUsesWith(retPhi);
Ins = newReturnBlock->getFirstNonPHI();
-
- retPhi->addIncoming(I, preReturn);
+
+ retPhi->addIncoming(&*I, preReturn);
retPhi->addIncoming(OldPhi->getIncomingValueForBlock(newEntryBlock),
newEntryBlock);
OldPhi->removeIncomingValue(newEntryBlock);
@@ -116,8 +116,8 @@ Function* PartialInliner::unswitchFuncti
FE = duplicateFunction->end(); FI != FE; ++FI)
if (&*FI != newEntryBlock && &*FI != newReturnBlock &&
&*FI != newNonReturnBlock)
- toExtract.push_back(FI);
-
+ toExtract.push_back(&*FI);
+
// The CodeExtractor needs a dominator tree.
DominatorTree DT;
DT.recalculate(*duplicateFunction);
Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Tue Oct 13 12:51:03 2015
@@ -233,7 +233,7 @@ bool PruneEH::SimplifyFunction(Function
// Remove the uncond branch and add an unreachable.
BB->getInstList().pop_back();
- new UnreachableInst(BB->getContext(), BB);
+ new UnreachableInst(BB->getContext(), &*BB);
DeleteBasicBlock(New); // Delete the new BB.
MadeChange = true;
Modified: llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp Tue Oct 13 12:51:03 2015
@@ -47,7 +47,7 @@ bool StripDeadPrototypesPass::runOnModul
// Erase dead function prototypes.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
- Function *F = I++;
+ Function *F = &*I++;
// Function must be a prototype and unused.
if (F->isDeclaration() && F->use_empty()) {
F->eraseFromParent();
@@ -59,7 +59,7 @@ bool StripDeadPrototypesPass::runOnModul
// Erase dead global var prototypes.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ) {
- GlobalVariable *GV = I++;
+ GlobalVariable *GV = &*I++;
// Global must be a prototype and unused.
if (GV->isDeclaration() && GV->use_empty())
GV->eraseFromParent();
Modified: llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp?rev=250187&r1=250186&r2=250187&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp Tue Oct 13 12:51:03 2015
@@ -211,13 +211,13 @@ static bool StripSymbolNames(Module &M,
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
- if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
+ if (I->hasLocalLinkage() && llvmUsedValues.count(&*I) == 0)
if (!PreserveDbgInfo || !I->getName().startswith("llvm.dbg"))
I->setName(""); // Internal symbols can't participate in linkage
}
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
- if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
+ if (I->hasLocalLinkage() && llvmUsedValues.count(&*I) == 0)
if (!PreserveDbgInfo || !I->getName().startswith("llvm.dbg"))
I->setName(""); // Internal symbols can't participate in linkage
StripSymtab(I->getValueSymbolTable(), PreserveDbgInfo);
More information about the llvm-commits
mailing list