6 changes: 3 additions & 3 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9515,7 +9515,7 @@ struct AAFunctionReachabilityFunction : public AAFunctionReachability {
ArrayRef<const AACallEdges *> AAEdgesList) {
ChangeStatus Change = ChangeStatus::UNCHANGED;

for (auto *AAEdges : AAEdgesList) {
for (const auto *AAEdges : AAEdgesList) {
if (AAEdges->hasUnknownCallee()) {
if (!CanReachUnknownCallee) {
LLVM_DEBUG(dbgs()
Expand Down Expand Up @@ -9563,7 +9563,7 @@ struct AAFunctionReachabilityFunction : public AAFunctionReachability {
const Function &Fn) const {

// Handle the most trivial case first.
for (auto *AAEdges : AAEdgesList) {
for (const auto *AAEdges : AAEdgesList) {
const SetVector<Function *> &Edges = AAEdges->getOptimisticEdges();

if (Edges.count(const_cast<Function *>(&Fn)))
Expand Down Expand Up @@ -9591,7 +9591,7 @@ struct AAFunctionReachabilityFunction : public AAFunctionReachability {
}

// The result is false for now, set dependencies and leave.
for (auto *Dep : Deps)
for (const auto *Dep : Deps)
A.recordDependence(*Dep, AA, DepClassTy::REQUIRED);

return false;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ static bool allUsesOfLoadedValueWillTrapIfNull(const GlobalVariable *GV) {
Worklist.push_back(GV);
while (!Worklist.empty()) {
const Value *P = Worklist.pop_back_val();
for (auto *U : P->users()) {
for (const auto *U : P->users()) {
if (auto *LI = dyn_cast<LoadInst>(U)) {
SmallPtrSet<const PHINode *, 8> PHIs;
if (!AllUsesOfValueWillTrapIfNull(LI, PHIs))
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,9 +1383,7 @@ bool DataFlowSanitizer::runImpl(Module &M) {
assert(isa<Function>(C) && "Personality routine is not a function!");
Function *F = cast<Function>(C);
if (!isInstrumented(F))
FnsToInstrument.erase(
std::remove(FnsToInstrument.begin(), FnsToInstrument.end(), F),
FnsToInstrument.end());
llvm::erase_value(FnsToInstrument, F);
}
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ bool ObjCARCOpt::VisitInstructionTopDown(
if (const SmallPtrSet<const Value *, 2> *Roots =
getRCIdentityRootsFromReleaseInsertPt(
Inst, ReleaseInsertPtToRCIdentityRoots))
for (auto *Root : *Roots) {
for (const auto *Root : *Roots) {
TopDownPtrState &S = MyStates.getPtrTopDownState(Root);
// Disable code motion if the current position is S_Retain to prevent
// moving the objc_retain call past objc_release calls. If it's
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ bool NewGVN::isCycleFree(const Instruction *I) const {
return isa<PHINode>(V) || isCopyOfAPHI(V);
});
ICS = AllPhis ? ICS_CycleFree : ICS_Cycle;
for (auto *Member : SCC)
for (const auto *Member : SCC)
if (auto *MemberPhi = dyn_cast<PHINode>(Member))
InstCycleState.insert({MemberPhi, ICS});
}
Expand Down Expand Up @@ -2090,7 +2090,7 @@ void NewGVN::markMemoryDefTouched(const MemoryAccess *MA) {
void NewGVN::markMemoryUsersTouched(const MemoryAccess *MA) {
if (isa<MemoryUse>(MA))
return;
for (auto U : MA->users())
for (const auto *U : MA->users())
TouchedInstructions.set(MemoryToDFSNum(U));
touchAndErase(MemoryToUsers, MA);
}
Expand All @@ -2102,7 +2102,7 @@ void NewGVN::markPredicateUsersTouched(Instruction *I) {

// Mark users affected by a memory leader change.
void NewGVN::markMemoryLeaderChangeTouched(CongruenceClass *CC) {
for (auto M : CC->memory())
for (const auto *M : CC->memory())
markMemoryDefTouched(M);
}

Expand Down Expand Up @@ -3151,7 +3151,7 @@ bool NewGVN::singleReachablePHIPath(
return true;

const auto *EndDef = First;
for (auto *ChainDef : optimized_def_chain(First)) {
for (const auto *ChainDef : optimized_def_chain(First)) {
if (ChainDef == Second)
return true;
if (MSSA->isLiveOnEntryDef(ChainDef))
Expand Down Expand Up @@ -3196,7 +3196,7 @@ void NewGVN::verifyMemoryCongruency() const {
assert(MemoryAccessToClass.lookup(CC->getMemoryLeader()) == CC &&
"Representative MemoryAccess does not appear to be reverse "
"mapped properly");
for (auto M : CC->memory())
for (const auto *M : CC->memory())
assert(MemoryAccessToClass.lookup(M) == CC &&
"Memory member does not appear to be reverse mapped properly");
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/CodeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static bool isBlockValidForExtraction(const BasicBlock &BB,
if (auto *UBB = CSI->getUnwindDest())
if (!Result.count(UBB))
return false;
for (auto *HBB : CSI->handlers())
for (const auto *HBB : CSI->handlers())
if (!Result.count(const_cast<BasicBlock*>(HBB)))
return false;
continue;
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Utils/CodeLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,7 @@ class ExtTSPImpl {
}

// Remove chain From from the list of active chains
auto Iter = std::remove(HotChains.begin(), HotChains.end(), From);
HotChains.erase(Iter, HotChains.end());
llvm::erase_value(HotChains, From);

// Invalidate caches
for (auto EdgeIter : Into->edges()) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ bool llvm::nonStrictlyPostDominate(const BasicBlock *ThisBlock,
if (PDT->dominates(CurBlock, OtherBlock))
return true;

for (auto *Pred : predecessors(CurBlock)) {
for (const auto *Pred : predecessors(CurBlock)) {
if (Pred == CommonDominator || Visited.count(Pred))
continue;
WorkList.push_back(Pred);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ static bool hasHardUserWithinLoop(const Loop *L, const Instruction *I) {
if (Curr->mayHaveSideEffects())
return true;
// Otherwise, add all its users to worklist.
for (auto U : Curr->users()) {
for (const auto *U : Curr->users()) {
auto *UI = cast<Instruction>(U);
if (Visited.insert(UI).second)
WorkList.push_back(UI);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ Value *SCEVExpander::expandUnionPredicate(const SCEVUnionPredicate *Union,
Instruction *IP) {
// Loop over all checks in this set.
SmallVector<Value *> Checks;
for (auto Pred : Union->getPredicates()) {
for (const auto *Pred : Union->getPredicates()) {
Checks.push_back(expandCodeForPredicate(Pred, IP));
Builder.SetInsertPoint(IP);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/SplitModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void addNonConstUser(ClusterMapType &GVtoClusterMap,
// Adds all GlobalValue users of V to the same cluster as GV.
static void addAllGlobalValueUsers(ClusterMapType &GVtoClusterMap,
const GlobalValue *GV, const Value *V) {
for (auto *U : V->users()) {
for (const auto *U : V->users()) {
SmallVector<const User *, 4> Worklist;
Worklist.push_back(U);
while (!Worklist.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9008,7 +9008,7 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
// Interleave memory: for each Interleave Group we marked earlier as relevant
// for this VPlan, replace the Recipes widening its memory instructions with a
// single VPInterleaveRecipe at its insertion point.
for (auto IG : InterleaveGroups) {
for (const auto *IG : InterleaveGroups) {
auto *Recipe = cast<VPWidenMemoryInstructionRecipe>(
RecipeBuilder.getRecipe(IG->getInsertPos()));
SmallVector<VPValue *, 4> StoredValues;
Expand Down
6 changes: 2 additions & 4 deletions llvm/tools/llvm-nm/llvm-nm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2287,10 +2287,8 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
}

// Delete symbols which should not be printed from SymolList.
SymbolList.erase(
llvm::remove_if(SymbolList,
[](const NMSymbol &s) { return !s.shouldPrint(); }),
SymbolList.end());
llvm::erase_if(SymbolList,
[](const NMSymbol &s) { return !s.shouldPrint(); });
sortSymbolList(SymbolList);
SymbolList.erase(std::unique(SymbolList.begin(), SymbolList.end()),
SymbolList.end());
Expand Down