2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/ADCE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void AggressiveDeadCodeElimination::initialize() {
// return of the function.
// We do this by seeing which of the postdomtree root children exit the
// program, and for all others, mark the subtree live.
for (auto &PDTChild : children<DomTreeNode *>(PDT.getRootNode())) {
for (const auto &PDTChild : children<DomTreeNode *>(PDT.getRootNode())) {
auto *BB = PDTChild->getBlock();
auto &Info = BlockInfo[BB];
// Real function return
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static void recordConditions(CallBase &CB, BasicBlock *Pred,
}

static void addConditions(CallBase &CB, const ConditionsTy &Conditions) {
for (auto &Cond : Conditions) {
for (const auto &Cond : Conditions) {
Value *Arg = Cond.first->getOperand(0);
Constant *ConstVal = cast<Constant>(Cond.first->getOperand(1));
if (Cond.second == ICmpInst::ICMP_EQ)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/GVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) {
// after the found access or before the terminator if no such access is
// found.
if (AL) {
for (auto &Acc : *AL) {
for (const auto &Acc : *AL) {
if (auto *Current = dyn_cast<MemoryUseOrDef>(&Acc))
if (!Current->getMemoryInst()->comesBefore(NewS)) {
FirstNonDom = Current;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/GVNHoist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class GVNHoist {
continue;
const VNType &VN = R;
SmallPtrSet<BasicBlock *, 2> VNBlocks;
for (auto &I : V) {
for (const auto &I : V) {
BasicBlock *BBI = I->getParent();
if (!hasEH(BBI))
VNBlocks.insert(BBI);
Expand Down Expand Up @@ -563,7 +563,7 @@ bool GVNHoist::run(Function &F) {
for (const BasicBlock *BB : depth_first(&F.getEntryBlock())) {
DFSNumber[BB] = ++BBI;
unsigned I = 0;
for (auto &Inst : *BB)
for (const auto &Inst : *BB)
DFSNumber[&Inst] = ++I;
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LoopDeletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static bool isLoopDead(Loop *L, ScalarEvolution &SE,
// Make sure that no instructions in the block have potential side-effects.
// This includes instructions that could write to memory, and loads that are
// marked volatile.
for (auto &I : L->blocks())
for (const auto &I : L->blocks())
if (any_of(*I, [](Instruction &I) {
return I.mayHaveSideEffects() && !I.isDroppable();
}))
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/LoopDistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ class MemoryInstructionDependences {
Accesses.append(Instructions.begin(), Instructions.end());

LLVM_DEBUG(dbgs() << "Backward dependences:\n");
for (auto &Dep : Dependences)
for (const auto &Dep : Dependences)
if (Dep.isPossiblyBackward()) {
// Note that the designations source and destination follow the program
// order, i.e. source is always first. (The direction is given by the
Expand Down Expand Up @@ -715,7 +715,7 @@ class LoopDistributeForLoop {
*Dependences);

int NumUnsafeDependencesActive = 0;
for (auto &InstDep : MID) {
for (const auto &InstDep : MID) {
Instruction *I = InstDep.Inst;
// We update NumUnsafeDependencesActive post-instruction, catch the
// start of a dependence directly via NumUnsafeDependencesStartOrEnd.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5980,7 +5980,7 @@ struct SCEVDbgValueBuilder {
"Expected arithmetic SCEV type");
bool Success = true;
unsigned EmitOperator = 0;
for (auto &Op : CommExpr->operands()) {
for (const auto &Op : CommExpr->operands()) {
Success &= pushSCEV(Op);

if (EmitOperator >= 1)
Expand Down Expand Up @@ -6490,7 +6490,7 @@ static void DbgGatherSalvagableDVI(
Loop *L, ScalarEvolution &SE,
SmallVector<std::unique_ptr<DVIRecoveryRec>, 2> &SalvageableDVISCEVs,
SmallSet<AssertingVH<DbgValueInst>, 2> &DVIHandles) {
for (auto &B : L->getBlocks()) {
for (const auto &B : L->getBlocks()) {
for (auto &I : *B) {
auto DVI = dyn_cast<DbgValueInst>(&I);
if (!DVI)
Expand Down Expand Up @@ -6637,7 +6637,7 @@ static bool ReduceLoopStrength(Loop *L, IVUsers &IU, ScalarEvolution &SE,
// Obtain relevant IVs and attempt to rewrite the salvageable DVIs with
// expressions composed using the derived iteration count.
// TODO: Allow for multiple IV references for nested AddRecSCEVs
for (auto &L : LI) {
for (const auto &L : LI) {
if (llvm::PHINode *IV = GetInductionVariable(*L, SE, Reducer))
DbgRewriteSalvageableDVIs(L, SE, IV, SalvageableDVIRecords);
else {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ PreservedAnalyses LoopUnrollPass::run(Function &F,
// legality and profitability checks. This means running the loop unroller
// will simplify all loops, regardless of whether anything end up being
// unrolled.
for (auto &L : LI) {
for (const auto &L : LI) {
Changed |=
simplifyLoop(L, &DT, &LI, &SE, &AC, nullptr, false /* PreserveLCSSA */);
Changed |= formLCSSARecursively(*L, DT, &LI, &SE);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ class LowerMatrixIntrinsics {
// the inlinedAt chain. If the function does not have a DISubprogram, we
// only map them to the containing function.
MapVector<DISubprogram *, SmallVector<Value *, 8>> Subprog2Exprs;
for (auto &KV : Inst2Matrix) {
for (const auto &KV : Inst2Matrix) {
if (Func.getSubprogram()) {
auto *I = cast<Instruction>(KV.first);
DILocation *Context = I->getDebugLoc();
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct TarjanSCC {
Root[I] = ++DFSNum;
// Store the DFS Number we had before it possibly gets incremented.
unsigned int OurDFS = DFSNum;
for (auto &Op : I->operands()) {
for (const auto &Op : I->operands()) {
if (auto *InstOp = dyn_cast<Instruction>(Op)) {
if (Root.lookup(Op) == 0)
FindSCC(InstOp);
Expand Down Expand Up @@ -3218,7 +3218,7 @@ void NewGVN::verifyMemoryCongruency() const {
// We could have phi nodes which operands are all trivially dead,
// so we don't process them.
if (auto *MemPHI = dyn_cast<MemoryPhi>(Pair.first)) {
for (auto &U : MemPHI->incoming_values()) {
for (const auto &U : MemPHI->incoming_values()) {
if (auto *I = dyn_cast<Instruction>(&*U)) {
if (!isInstructionTriviallyDead(I))
return true;
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ deleteDeadClonedBlocks(Loop &L, ArrayRef<BasicBlock *> ExitBlocks,
// Find all the dead clones, and remove them from their successors.
SmallVector<BasicBlock *, 16> DeadBlocks;
for (BasicBlock *BB : llvm::concat<BasicBlock *const>(L.blocks(), ExitBlocks))
for (auto &VMap : VMaps)
for (const auto &VMap : VMaps)
if (BasicBlock *ClonedBB = cast_or_null<BasicBlock>(VMap->lookup(BB)))
if (!DT.isReachableFromEntry(ClonedBB)) {
for (BasicBlock *SuccBB : successors(ClonedBB))
Expand Down Expand Up @@ -2247,7 +2247,7 @@ static void unswitchNontrivialInvariants(
assert(SI->getDefaultDest() == RetainedSuccBB &&
"Not retaining default successor!");
SI->setDefaultDest(LoopPH);
for (auto &Case : SI->cases())
for (const auto &Case : SI->cases())
if (Case.getCaseSuccessor() == RetainedSuccBB)
Case.setSuccessor(LoopPH);
else
Expand Down Expand Up @@ -2308,7 +2308,7 @@ static void unswitchNontrivialInvariants(
SwitchInst *NewSI = cast<SwitchInst>(NewTI);
assert(NewSI->getDefaultDest() == RetainedSuccBB &&
"Not retaining default successor!");
for (auto &Case : NewSI->cases())
for (const auto &Case : NewSI->cases())
Case.getCaseSuccessor()->removePredecessor(
ParentBB,
/*KeepOneInputPHIs*/ true);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Utils/CodeLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ class ExtTSPImpl {
});

double Score = 0;
for (auto &Jump : Jumps) {
for (const auto &Jump : Jumps) {
const auto SrcBlock = Jump->Source;
const auto DstBlock = Jump->Target;
Score += ::extTSPScore(SrcBlock->EstimatedAddr, SrcBlock->Size,
Expand Down Expand Up @@ -711,7 +711,7 @@ class ExtTSPImpl {
return;
// Apply the merge, compute the corresponding gain, and update the best
// value, if the merge is beneficial
for (auto &MergeType : MergeTypes) {
for (const auto &MergeType : MergeTypes) {
Gain.updateIfLessThan(
computeMergeGain(ChainPred, ChainSucc, Jumps, Offset, MergeType));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) {
if (VI && ImportIndex.hasSyntheticEntryCounts()) {
if (Function *F = dyn_cast<Function>(&GV)) {
if (!F->isDeclaration()) {
for (auto &S : VI.getSummaryList()) {
for (const auto &S : VI.getSummaryList()) {
auto *FS = cast<FunctionSummary>(S->getBaseObject());
if (FS->modulePath() == M.getModuleIdentifier()) {
F->setEntryCount(Function::ProfileCount(FS->entryCount(),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LCSSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ bool llvm::formLCSSARecursively(Loop &L, const DominatorTree &DT,
static bool formLCSSAOnAllLoops(const LoopInfo *LI, const DominatorTree &DT,
ScalarEvolution *SE) {
bool Changed = false;
for (auto &L : *LI)
for (const auto &L : *LI)
Changed |= formLCSSARecursively(*L, DT, LI, SE);
return Changed;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ bool llvm::LowerDbgDeclare(Function &F) {
WorkList.push_back(AI);
while (!WorkList.empty()) {
const Value *V = WorkList.pop_back_val();
for (auto &AIUse : V->uses()) {
for (const auto &AIUse : V->uses()) {
User *U = AIUse.getUser();
if (StoreInst *SI = dyn_cast<StoreInst>(U)) {
if (AIUse.getOperandNo() == 1)
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Transforms/Utils/SampleProfileInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class MinCostMaxFlow {
/// Returns a list of pairs (target node, amount of flow to the target).
const std::vector<std::pair<uint64_t, int64_t>> getFlow(uint64_t Src) const {
std::vector<std::pair<uint64_t, int64_t>> Flow;
for (auto &Edge : Edges[Src]) {
for (const auto &Edge : Edges[Src]) {
if (Edge.Flow > 0)
Flow.push_back(std::make_pair(Edge.Dst, Edge.Flow));
}
Expand All @@ -158,7 +158,7 @@ class MinCostMaxFlow {
/// Get the total flow between a pair of nodes.
int64_t getFlow(uint64_t Src, uint64_t Dst) const {
int64_t Flow = 0;
for (auto &Edge : Edges[Src]) {
for (const auto &Edge : Edges[Src]) {
if (Edge.Dst == Dst) {
Flow += Edge.Flow;
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@ void extractWeights(MinCostMaxFlow &Network, FlowFunction &Func) {
auto &Block = Func.Blocks[Src];
uint64_t SrcOut = 3 * Src + 1;
int64_t Flow = 0;
for (auto &Adj : Network.getFlow(SrcOut)) {
for (const auto &Adj : Network.getFlow(SrcOut)) {
uint64_t DstIn = Adj.first;
int64_t DstFlow = Adj.second;
bool IsAuxNode = (DstIn < 3 * NumBlocks && DstIn % 3 == 2);
Expand Down Expand Up @@ -1176,7 +1176,7 @@ void verifyWeights(const FlowFunction &Func) {
const uint64_t NumBlocks = Func.Blocks.size();
auto InFlow = std::vector<uint64_t>(NumBlocks, 0);
auto OutFlow = std::vector<uint64_t>(NumBlocks, 0);
for (auto &Jump : Func.Jumps) {
for (const auto &Jump : Func.Jumps) {
InFlow[Jump.Target] += Jump.Flow;
OutFlow[Jump.Source] += Jump.Flow;
}
Expand All @@ -1202,7 +1202,7 @@ void verifyWeights(const FlowFunction &Func) {
// One could modify FlowFunction to hold edges indexed by the sources, which
// will avoid a creation of the object
auto PositiveFlowEdges = std::vector<std::vector<uint64_t>>(NumBlocks);
for (auto &Jump : Func.Jumps) {
for (const auto &Jump : Func.Jumps) {
if (Jump.Flow > 0) {
PositiveFlowEdges[Jump.Source].push_back(Jump.Target);
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5272,7 +5272,7 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, DomTreeUpdater *DTU,
SmallVector<ConstantInt *, 8> DeadCases;
SmallDenseMap<BasicBlock *, int, 8> NumPerSuccessorCases;
SmallVector<BasicBlock *, 8> UniqueSuccessors;
for (auto &Case : SI->cases()) {
for (const auto &Case : SI->cases()) {
auto *Successor = Case.getCaseSuccessor();
if (DTU) {
if (!NumPerSuccessorCases.count(Successor))
Expand Down Expand Up @@ -5372,7 +5372,7 @@ static bool ForwardSwitchConditionToPHI(SwitchInst *SI) {
ForwardingNodesMap ForwardingNodes;
BasicBlock *SwitchBlock = SI->getParent();
bool Changed = false;
for (auto &Case : SI->cases()) {
for (const auto &Case : SI->cases()) {
ConstantInt *CaseValue = Case.getCaseValue();
BasicBlock *CaseDest = Case.getCaseSuccessor();

Expand Down Expand Up @@ -5588,7 +5588,7 @@ static bool initializeUniqueCases(SwitchInst *SI, PHINode *&PHI,
const DataLayout &DL,
const TargetTransformInfo &TTI,
uintptr_t MaxUniqueResults) {
for (auto &I : SI->cases()) {
for (const auto &I : SI->cases()) {
ConstantInt *CaseVal = I.getCaseValue();

// Resulting value at phi nodes for this case value.
Expand Down Expand Up @@ -6494,7 +6494,7 @@ static bool ReduceSwitchRange(SwitchInst *SI, IRBuilder<> &Builder,
// cases such as a sequence crossing zero {-4,0,4,8} if we interpret case values
// as signed.
SmallVector<int64_t,4> Values;
for (auto &C : SI->cases())
for (const auto &C : SI->cases())
Values.push_back(C.getCaseValue()->getValue().getSExtValue());
llvm::sort(Values);

Expand Down Expand Up @@ -7043,7 +7043,7 @@ static bool removeUndefIntroducingPredecessor(BasicBlock *BB,
Builder.SetInsertPoint(Unreachable);
// The new block contains only one instruction: Unreachable
Builder.CreateUnreachable();
for (auto &Case : SI->cases())
for (const auto &Case : SI->cases())
if (Case.getCaseSuccessor() == BB) {
BB->removePredecessor(Predecessor);
Case.setSuccessor(Unreachable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ bool LoopVectorizationLegality::prepareToFoldTailByMasking() {

SmallPtrSet<const Value *, 8> ReductionLiveOuts;

for (auto &Reduction : getReductionVars())
for (const auto &Reduction : getReductionVars())
ReductionLiveOuts.insert(Reduction.second.getLoopExitInstr());

// TODO: handle non-reduction outside users when tail is folded by masking.
Expand Down
38 changes: 19 additions & 19 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2755,7 +2755,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr,

// Replace the operands of the cloned instructions with their scalar
// equivalents in the new loop.
for (auto &I : enumerate(RepRecipe->operands())) {
for (const auto &I : enumerate(RepRecipe->operands())) {
auto InputInstance = Instance;
VPValue *Operand = I.value();
VPReplicateRecipe *OperandR = dyn_cast<VPReplicateRecipe>(Operand);
Expand Down Expand Up @@ -3100,7 +3100,7 @@ void InnerLoopVectorizer::createInductionResumeValues(
// If we come from a bypass edge then we need to start from the original
// start value.
Instruction *OldInduction = Legal->getPrimaryInduction();
for (auto &InductionEntry : Legal->getInductionVars()) {
for (const auto &InductionEntry : Legal->getInductionVars()) {
PHINode *OrigPhi = InductionEntry.first;
InductionDescriptor II = InductionEntry.second;

Expand Down Expand Up @@ -3655,7 +3655,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State,
// edge.

// Fix-up external users of the induction variables.
for (auto &Entry : Legal->getInductionVars())
for (const auto &Entry : Legal->getInductionVars())
fixupIVUsers(Entry.first, Entry.second,
getOrCreateVectorTripCount(VectorLoop->getLoopPreheader()),
IVEndValues[Entry.first], LoopMiddleBlock,
Expand All @@ -3665,7 +3665,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State,
// Fix LCSSA phis not already fixed earlier. Extracts may need to be generated
// in the exit block, so update the builder.
State.Builder.SetInsertPoint(State.CFG.ExitBB->getFirstNonPHI());
for (auto &KV : Plan.getLiveOuts())
for (const auto &KV : Plan.getLiveOuts())
KV.second->fixPhi(Plan, State);

for (Instruction *PI : PredicatedInstructions)
Expand Down Expand Up @@ -4182,7 +4182,7 @@ void InnerLoopVectorizer::widenCallInstruction(CallInst &CI, VPValue *Def,
for (unsigned Part = 0; Part < UF; ++Part) {
SmallVector<Type *, 2> TysForDecl = {CI.getType()};
SmallVector<Value *, 4> Args;
for (auto &I : enumerate(ArgOperands.operands())) {
for (const auto &I : enumerate(ArgOperands.operands())) {
// Some intrinsics have a scalar argument - don't replace it with a
// vector.
Value *Arg;
Expand Down Expand Up @@ -4359,7 +4359,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {

// An induction variable will remain scalar if all users of the induction
// variable and induction variable update remain scalar.
for (auto &Induction : Legal->getInductionVars()) {
for (const auto &Induction : Legal->getInductionVars()) {
auto *Ind = Induction.first;
auto *IndUpdate = cast<Instruction>(Ind->getIncomingValueForBlock(Latch));

Expand Down Expand Up @@ -4749,7 +4749,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
// nodes separately. An induction variable will remain uniform if all users
// of the induction variable and induction variable update remain uniform.
// The code below handles both pointer and non-pointer induction variables.
for (auto &Induction : Legal->getInductionVars()) {
for (const auto &Induction : Legal->getInductionVars()) {
auto *Ind = Induction.first;
auto *IndUpdate = cast<Instruction>(Ind->getIncomingValueForBlock(Latch));

Expand Down Expand Up @@ -5381,7 +5381,7 @@ VectorizationFactor LoopVectorizationCostModel::selectVectorizationFactor(
raw_string_ostream OS(OutString);
assert(!Subset.empty() && "Unexpected empty range");
OS << "Instruction with invalid costs prevented vectorization at VF=(";
for (auto &Pair : Subset)
for (const auto &Pair : Subset)
OS << (Pair.second == Subset.front().second ? "" : ", ")
<< Pair.second;
OS << "):";
Expand Down Expand Up @@ -5424,7 +5424,7 @@ bool LoopVectorizationCostModel::isCandidateForEpilogueVectorization(

// Phis with uses outside of the loop require special handling and are
// currently unsupported.
for (auto &Entry : Legal->getInductionVars()) {
for (const auto &Entry : Legal->getInductionVars()) {
// Look for uses of the value of the induction at the last iteration.
Value *PostInc = Entry.first->getIncomingValueForBlock(L.getLoopLatch());
for (User *U : PostInc->users())
Expand Down Expand Up @@ -5558,7 +5558,7 @@ LoopVectorizationCostModel::getSmallestAndWidestTypes() {
// Reset MaxWidth so that we can find the smallest type used by recurrences
// in the loop.
MaxWidth = -1U;
for (auto &PhiDescriptorPair : Legal->getReductionVars()) {
for (const auto &PhiDescriptorPair : Legal->getReductionVars()) {
const RecurrenceDescriptor &RdxDesc = PhiDescriptorPair.second;
// When finding the min width used by the recurrence we need to account
// for casts on the input operands of the recurrence.
Expand Down Expand Up @@ -7342,22 +7342,22 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {

// Ignore type-promoting instructions we identified during reduction
// detection.
for (auto &Reduction : Legal->getReductionVars()) {
for (const auto &Reduction : Legal->getReductionVars()) {
const RecurrenceDescriptor &RedDes = Reduction.second;
const SmallPtrSetImpl<Instruction *> &Casts = RedDes.getCastInsts();
VecValuesToIgnore.insert(Casts.begin(), Casts.end());
}
// Ignore type-casting instructions we identified during induction
// detection.
for (auto &Induction : Legal->getInductionVars()) {
for (const auto &Induction : Legal->getInductionVars()) {
const InductionDescriptor &IndDes = Induction.second;
const SmallVectorImpl<Instruction *> &Casts = IndDes.getCastInsts();
VecValuesToIgnore.insert(Casts.begin(), Casts.end());
}
}

void LoopVectorizationCostModel::collectInLoopReductions() {
for (auto &Reduction : Legal->getReductionVars()) {
for (const auto &Reduction : Legal->getReductionVars()) {
PHINode *Phi = Reduction.first;
const RecurrenceDescriptor &RdxDesc = Reduction.second;

Expand Down Expand Up @@ -8721,18 +8721,18 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(

// Mark instructions we'll need to sink later and their targets as
// ingredients whose recipe we'll need to record.
for (auto &Entry : SinkAfter) {
for (const auto &Entry : SinkAfter) {
RecipeBuilder.recordRecipeOf(Entry.first);
RecipeBuilder.recordRecipeOf(Entry.second);
}
for (auto &Reduction : CM.getInLoopReductionChains()) {
for (const auto &Reduction : CM.getInLoopReductionChains()) {
PHINode *Phi = Reduction.first;
RecurKind Kind =
Legal->getReductionVars().find(Phi)->second.getRecurrenceKind();
const SmallVector<Instruction *, 4> &ReductionOperations = Reduction.second;

RecipeBuilder.recordRecipeOf(Phi);
for (auto &R : ReductionOperations) {
for (const auto &R : ReductionOperations) {
RecipeBuilder.recordRecipeOf(R);
// For min/max reductions, where we have a pair of icmp/select, we also
// need to record the ICmp recipe, so it can be removed later.
Expand Down Expand Up @@ -8913,7 +8913,7 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
}
return nullptr;
};
for (auto &Entry : SinkAfter) {
for (const auto &Entry : SinkAfter) {
VPRecipeBase *Sink = RecipeBuilder.getRecipe(Entry.first);
VPRecipeBase *Target = RecipeBuilder.getRecipe(Entry.second);

Expand Down Expand Up @@ -9112,7 +9112,7 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
void LoopVectorizationPlanner::adjustRecipesForReductions(
VPBasicBlock *LatchVPBB, VPlanPtr &Plan, VPRecipeBuilder &RecipeBuilder,
ElementCount MinVF) {
for (auto &Reduction : CM.getInLoopReductionChains()) {
for (const auto &Reduction : CM.getInLoopReductionChains()) {
PHINode *Phi = Reduction.first;
const RecurrenceDescriptor &RdxDesc =
Legal->getReductionVars().find(Phi)->second;
Expand Down Expand Up @@ -10496,7 +10496,7 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
// legality and profitability checks. This means running the loop vectorizer
// will simplify all loops, regardless of whether anything end up being
// vectorized.
for (auto &L : *LI)
for (const auto &L : *LI)
Changed |= CFGChanged |=
simplifyLoop(L, DT, LI, SE, AC, nullptr, false /* PreserveLCSSA */);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ void VPlan::print(raw_ostream &O) const {

if (!LiveOuts.empty())
O << "\n";
for (auto &KV : LiveOuts) {
for (const auto &KV : LiveOuts) {
O << "Live-out ";
KV.second->getPhi()->printAsOperand(O);
O << " = ";
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ bool VPlanVerifier::verifyPlanIsValid(const VPlan &Plan) {
}
}

for (auto &KV : Plan.getLiveOuts())
for (const auto &KV : Plan.getLiveOuts())
if (KV.second->getNumOperands() != 1) {
errs() << "live outs must have a single operand\n";
return false;
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/ADT/StatisticTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ TEST(StatisticTest, API) {
// It should empty the list and zero the counters.
ResetStatistics();
{
auto &Range = GetStatistics();
auto Range = GetStatistics();
EXPECT_EQ(Range.begin(), Range.end());
EXPECT_EQ(Counter, 0u);
EXPECT_EQ(Counter2, 0u);
Expand All @@ -144,7 +144,7 @@ TEST(StatisticTest, API) {
Counter2++;

{
auto &Range = GetStatistics();
auto Range = GetStatistics();
EXPECT_EQ(Range.begin() + 2, Range.end());
EXPECT_EQ(Counter, 1u);
EXPECT_EQ(Counter2, 1u);
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct Decompose : public Transformation {
struct Peel : public Transformation {
explicit Peel(linalg::LinalgPeelOptions options,
LinalgTransformationFilter::FilterFunction f = nullptr)
: Transformation(std::move(f)), opName(), options(options) {}
: Transformation(std::move(f)), options(options) {}

Peel(StringRef name, linalg::LinalgPeelOptions options,
LinalgTransformationFilter::FilterFunction f = nullptr)
Expand All @@ -149,7 +149,7 @@ struct Vectorize : public Transformation {
explicit Vectorize(linalg::LinalgVectorizationOptions options,
LinalgTransformationFilter::FilterFunction f = nullptr,
bool padVectorize = false)
: Transformation(std::move(f)), opName(), options(options),
: Transformation(std::move(f)), options(options),
vectorizePadding(padVectorize) {}

Vectorize(StringRef name, linalg::LinalgVectorizationOptions options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class [[nodiscard]] DiagnosedSilenceableFailure {

private:
explicit DiagnosedSilenceableFailure(Diagnostic &&diagnostic)
: diagnostics(), result(failure()) {
: result(failure()) {
diagnostics.emplace_back(std::move(diagnostic));
}
explicit DiagnosedSilenceableFailure(SmallVector<Diagnostic> &&diagnostics)
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Support/Timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class Timer {
/// started and stopped.
class TimingScope {
public:
TimingScope() : timer() {}
TimingScope() {}
TimingScope(const Timer &other) : timer(other) {
if (timer)
timer.start();
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Analysis/SliceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ namespace {
/// We traverse all operations but only record the ones that appear in
/// `toSort` for the final result.
struct DFSState {
DFSState(const SetVector<Operation *> &set)
: toSort(set), topologicalCounts(), seen() {}
DFSState(const SetVector<Operation *> &set) : toSort(set), seen() {}
const SetVector<Operation *> &toSort;
SmallVector<Operation *, 16> topologicalCounts;
DenseSet<Operation *> seen;
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ void NestedPattern::freeNested() {

NestedPattern::NestedPattern(ArrayRef<NestedPattern> nested,
FilterFunctionType filter)
: nestedPatterns(), filter(std::move(filter)), skip(nullptr) {
: filter(std::move(filter)), skip(nullptr) {
copyNestedToThis(nested);
}

NestedPattern::NestedPattern(const NestedPattern &other)
: nestedPatterns(), filter(other.filter), skip(other.skip) {
: filter(other.filter), skip(other.skip) {
copyNestedToThis(other.nestedPatterns);
}

Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Arithmetic/Transforms/Bufferize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace {
struct ArithmeticBufferizePass
: public ArithmeticBufferizeBase<ArithmeticBufferizePass> {
ArithmeticBufferizePass(uint64_t alignment = 0, bool constantOpOnly = false)
: ArithmeticBufferizeBase<ArithmeticBufferizePass>(),
constantOpOnly(constantOpOnly) {
: constantOpOnly(constantOpOnly) {
this->alignment = alignment;
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ parseLayoutMapOption(const std::string &s) {

struct OneShotBufferizePass
: public OneShotBufferizeBase<OneShotBufferizePass> {
OneShotBufferizePass() : OneShotBufferizeBase<OneShotBufferizePass>() {}
OneShotBufferizePass() {}

explicit OneShotBufferizePass(const OneShotBufferizationOptions &options)
: options(options) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,9 @@ mlir::bufferization::insertTensorCopies(Operation *op,
namespace {
struct TensorCopyInsertionPass
: TensorCopyInsertionBase<TensorCopyInsertionPass> {
TensorCopyInsertionPass()
: TensorCopyInsertionBase<TensorCopyInsertionPass>(),
options(llvm::None) {}
TensorCopyInsertionPass() : options(llvm::None) {}
TensorCopyInsertionPass(const OneShotBufferizationOptions &options)
: TensorCopyInsertionBase<TensorCopyInsertionPass>(), options(options) {}
: options(options) {}

void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<bufferization::BufferizationDialect>();
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter(
mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter(
const FilterFunction &f, ArrayRef<StringAttr> matchDisjunction,
Optional<StringAttr> replacement)
: filters(),
matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()),
: matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()),
replacement(replacement), matchByDefault(false) {
if (f)
filters.push_back(f);
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ struct spirv::detail::StructTypeStorage : public TypeStorage {
StructType::MemberDecorationInfo const *memberDecorationsInfo)
: memberTypesAndIsBodySet(memberTypes, false), offsetInfo(layoutInfo),
numMembers(numMembers), numMemberDecorations(numMemberDecorations),
memberDecorationsInfo(memberDecorationsInfo), identifier(StringRef()) {}
memberDecorationsInfo(memberDecorationsInfo) {}

/// A storage key is divided into 2 parts:
/// - for identified structs:
Expand Down Expand Up @@ -1076,7 +1076,7 @@ llvm::hash_code spirv::hash_value(

struct spirv::detail::MatrixTypeStorage : public TypeStorage {
MatrixTypeStorage(Type columnType, uint32_t columnCount)
: TypeStorage(), columnType(columnType), columnCount(columnCount) {}
: columnType(columnType), columnCount(columnCount) {}

using KeyTy = std::tuple<Type, uint32_t>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class BufferizeDenseOpsPass
public:
BufferizeDenseOpsPass(
const bufferization::OneShotBufferizationOptions &options)
: PassWrapper<BufferizeDenseOpsPass, OperationPass<ModuleOp>>(),
options(options) {}
: options(options) {}

void runOnOperation() override {
// Disallow all sparse tensor ops, so that only dense tensor ops are
Expand Down
5 changes: 2 additions & 3 deletions mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ struct CodeGen {
indices(numTensors, std::vector<Value>(numLoops)),
highs(numTensors, std::vector<Value>(numLoops)),
pidxs(numTensors, std::vector<Value>(numLoops)),
idxs(numTensors, std::vector<Value>(numLoops)), redVal(), sparseOut(op),
outerParNest(nest), lexIdx(), lexVal(), expValues(), expFilled(),
expAdded(), expCount(), curVecMask() {}
idxs(numTensors, std::vector<Value>(numLoops)), sparseOut(op),
outerParNest(nest) {}
/// Sparsification options.
SparsificationOptions options;
/// Universal dense indices and upper bounds (by index). The loops array
Expand Down
5 changes: 2 additions & 3 deletions mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ TensorExp::TensorExp(Kind k, unsigned x, unsigned y, Value v, Operation *o)
}

LatPoint::LatPoint(unsigned n, unsigned e, unsigned b)
: bits(n, false), simple(), exp(e) {
: bits(n, false), exp(e) {
bits.set(b);
}

LatPoint::LatPoint(const BitVector &b, unsigned e)
: bits(b), simple(), exp(e) {}
LatPoint::LatPoint(const BitVector &b, unsigned e) : bits(b), exp(e) {}

//===----------------------------------------------------------------------===//
// Lattice methods.
Expand Down
3 changes: 1 addition & 2 deletions mlir/test/lib/Dialect/Test/TestTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ namespace test {
struct TestRecursiveTypeStorage : public ::mlir::TypeStorage {
using KeyTy = ::llvm::StringRef;

explicit TestRecursiveTypeStorage(::llvm::StringRef key)
: name(key), body(::mlir::Type()) {}
explicit TestRecursiveTypeStorage(::llvm::StringRef key) : name(key) {}

bool operator==(const KeyTy &other) const { return name == other; }

Expand Down