diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 8addbde40c4f8..7de1e0cd48b31 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1442,7 +1442,7 @@ void BlockFrequencyInfoImpl::iterativeInference( // Successors[I] holds unique sucessors of the I-th block auto Successors = std::vector>(Freq.size()); for (size_t I = 0; I < Freq.size(); I++) { - for (auto &Jump : ProbMatrix[I]) { + for (const auto &Jump : ProbMatrix[I]) { Successors[Jump.first].push_back(I); } } @@ -1472,7 +1472,7 @@ void BlockFrequencyInfoImpl::iterativeInference( // (1.0 - SelfProb), where SelfProb is the sum of probabilities on the edges Scaled64 NewFreq; Scaled64 OneMinusSelfProb = Scaled64::getOne(); - for (auto &Jump : ProbMatrix[I]) { + for (const auto &Jump : ProbMatrix[I]) { if (Jump.first == I) { OneMinusSelfProb -= Jump.second; } else { diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h index b29854cddc66a..c8bc8b6e2f45e 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -77,7 +77,7 @@ class SCEVConstant : public SCEV { inline unsigned short computeExpressionSize(ArrayRef Args) { APInt Size(16, 1); - for (auto *Arg : Args) + for (const auto *Arg : Args) Size = Size.uadd_sat(APInt(16, Arg->getExpressionSize())); return (unsigned short)Size.getZExtValue(); } @@ -810,7 +810,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitAddExpr(const SCEVAddExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -820,7 +820,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitMulExpr(const SCEVMulExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -837,7 +837,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -849,7 +849,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -859,7 +859,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -869,7 +869,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitSMinExpr(const SCEVSMinExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -879,7 +879,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitUMinExpr(const SCEVUMinExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } @@ -889,7 +889,7 @@ class SCEVRewriteVisitor : public SCEVVisitor { const SCEV *visitSequentialUMinExpr(const SCEVSequentialUMinExpr *Expr) { SmallVector Operands; bool Changed = false; - for (auto *Op : Expr->operands()) { + for (const auto *Op : Expr->operands()) { Operands.push_back(((SC *)this)->visit(Op)); Changed |= Op != Operands.back(); } diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index df2826b50784d..f86ef14ffb75b 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -192,7 +192,7 @@ class SymbolLookupSet { std::initializer_list Names, SymbolLookupFlags Flags = SymbolLookupFlags::RequiredSymbol) { Symbols.reserve(Names.size()); - for (auto &Name : Names) + for (const auto &Name : Names) add(std::move(Name), Flags); } @@ -331,7 +331,7 @@ class SymbolLookupSet { SymbolNameVector getSymbolNames() const { SymbolNameVector Names; Names.reserve(Symbols.size()); - for (auto &KV : Symbols) + for (const auto &KV : Symbols) Names.push_back(KV.first); return Names; } diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h index 105dac8e8d043..88a2796ed23ba 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h @@ -228,7 +228,7 @@ class ExecutorProcessControl { /// found. If any symbol is not found then the function returns an error. Error getBootstrapSymbols( ArrayRef> Pairs) const { - for (auto &KV : Pairs) { + for (const auto &KV : Pairs) { auto I = BootstrapSymbols.find(KV.second); if (I == BootstrapSymbols.end()) return make_error("Symbol \"" + KV.second + diff --git a/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h index 4d6d46595fc3c..d659d6ae6b49a 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h @@ -385,7 +385,7 @@ class LocalIndirectStubsManager : public IndirectStubsManager { if (auto Err = reserveStubs(StubInits.size())) return Err; - for (auto &Entry : StubInits) + for (const auto &Entry : StubInits) createStubInternal(Entry.first(), Entry.second.first, Entry.second.second); diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 6903559da4e89..3b2c699a32d11 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -222,7 +222,7 @@ class IRBuilderBase { /// Add all entries in MetadataToCopy to \p I. void AddMetadataToInst(Instruction *I) const { - for (auto &KV : MetadataToCopy) + for (const auto &KV : MetadataToCopy) I->setMetadata(KV.first, KV.second); } diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index eb6f89d740c6a..bca243cd91f9f 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -2076,7 +2076,7 @@ class CallBase : public Instruction { /// Return true if this operand bundle user has operand bundles that /// may write to the heap. bool hasClobberingOperandBundles() const { - for (auto &BOI : bundle_op_infos()) { + for (const auto &BOI : bundle_op_infos()) { if (BOI.Tag->second == LLVMContext::OB_deopt || BOI.Tag->second == LLVMContext::OB_funclet || BOI.Tag->second == LLVMContext::OB_ptrauth) @@ -2300,7 +2300,7 @@ class CallBase : public Instruction { /// Return the total number of values used in \p Bundles. static unsigned CountBundleInputs(ArrayRef Bundles) { unsigned Total = 0; - for (auto &B : Bundles) + for (const auto &B : Bundles) Total += B.input_size(); return Total; } diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h index 203f7b3a18ba9..9f25b5a1e5503 100644 --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -1223,7 +1223,7 @@ class ModuleSummaryIndex { dyn_cast(V.getSummaryList().front().get()); assert(F != nullptr && "Expected FunctionSummary node"); - for (auto &C : F->calls()) { + for (const auto &C : F->calls()) { // Insert node if necessary auto S = FunctionHasParent.emplace(C.first, true); @@ -1572,9 +1572,9 @@ class ModuleSummaryIndex { template void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const { - for (auto &GlobalList : *this) { + for (const auto &GlobalList : *this) { auto GUID = GlobalList.first; - for (auto &Summary : GlobalList.second.SummaryList) { + for (const auto &Summary : GlobalList.second.SummaryList) { ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get(); } } diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index 12f9052a9eddc..a001e38da3e22 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -230,11 +230,11 @@ class PreservedAnalyses { } // The intersection requires the *union* of the explicitly not-preserved // IDs and the *intersection* of the preserved IDs. - for (auto ID : Arg.NotPreservedAnalysisIDs) { + for (auto *ID : Arg.NotPreservedAnalysisIDs) { PreservedIDs.erase(ID); NotPreservedAnalysisIDs.insert(ID); } - for (auto ID : PreservedIDs) + for (auto *ID : PreservedIDs) if (!Arg.PreservedIDs.count(ID)) PreservedIDs.erase(ID); } @@ -252,11 +252,11 @@ class PreservedAnalyses { } // The intersection requires the *union* of the explicitly not-preserved // IDs and the *intersection* of the preserved IDs. - for (auto ID : Arg.NotPreservedAnalysisIDs) { + for (auto *ID : Arg.NotPreservedAnalysisIDs) { PreservedIDs.erase(ID); NotPreservedAnalysisIDs.insert(ID); } - for (auto ID : PreservedIDs) + for (auto *ID : PreservedIDs) if (!Arg.PreservedIDs.count(ID)) PreservedIDs.erase(ID); } @@ -1104,7 +1104,7 @@ class OuterAnalysisManagerProxy DeadKeys.push_back(OuterID); } - for (auto OuterID : DeadKeys) + for (auto *OuterID : DeadKeys) OuterAnalysisInvalidationMap.erase(OuterID); // The proxy itself remains valid regardless of anything else. diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index ed2f70b0da251..98f6bea054314 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -176,7 +176,7 @@ class ELFSymbolRef : public SymbolRef { StringRef getELFTypeName() const { uint8_t Type = getELFType(); - for (auto &EE : ElfSymbolTypes) { + for (const auto &EE : ElfSymbolTypes) { if (EE.Value == Type) { return EE.AltName; } diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index 401d278cbd06d..cce2a8faf4dda 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -908,7 +908,7 @@ uint32_t InstrProfRecord::getNumValueKinds() const { uint32_t InstrProfRecord::getNumValueData(uint32_t ValueKind) const { uint32_t N = 0; - for (auto &SR : getValueSitesForKind(ValueKind)) + for (const auto &SR : getValueSitesForKind(ValueKind)) N += SR.ValueData.size(); return N; } diff --git a/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h b/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h index 96105d6b4684b..5723fb58edcd8 100644 --- a/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h +++ b/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h @@ -193,7 +193,7 @@ void IDFCalculatorBase::calculate( SuccNode, std::make_pair(SuccLevel, SuccNode->getDFSNumIn()))); }; - for (auto Succ : ChildrenGetter.get(BB)) + for (auto *Succ : ChildrenGetter.get(BB)) DoWork(Succ); for (auto DomChild : *Node) { diff --git a/llvm/include/llvm/Transforms/Utils/Evaluator.h b/llvm/include/llvm/Transforms/Utils/Evaluator.h index 2b8384897c6b3..6b9b382dbaf4f 100644 --- a/llvm/include/llvm/Transforms/Utils/Evaluator.h +++ b/llvm/include/llvm/Transforms/Utils/Evaluator.h @@ -101,7 +101,7 @@ class Evaluator { DenseMap getMutatedInitializers() const { DenseMap Result; - for (auto &Pair : MutatedMemory) + for (const auto &Pair : MutatedMemory) Result[Pair.first] = Pair.second.toConstant(); return Result; } diff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h index 4f878928a7bf1..79004a4c535ac 100644 --- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h +++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h @@ -198,14 +198,14 @@ class SCEVExpander : public SCEVVisitor { /// Return a vector containing all instructions inserted during expansion. SmallVector getAllInsertedInstructions() const { SmallVector Result; - for (auto &VH : InsertedValues) { + for (const auto &VH : InsertedValues) { Value *V = VH; if (ReusedValues.contains(V)) continue; if (auto *Inst = dyn_cast(V)) Result.push_back(Inst); } - for (auto &VH : InsertedPostIncValues) { + for (const auto &VH : InsertedPostIncValues) { Value *V = VH; if (ReusedValues.contains(V)) continue; diff --git a/llvm/lib/Analysis/MemoryProfileInfo.cpp b/llvm/lib/Analysis/MemoryProfileInfo.cpp index 3d11cb81226e3..f28ddbbfc8498 100644 --- a/llvm/lib/Analysis/MemoryProfileInfo.cpp +++ b/llvm/lib/Analysis/MemoryProfileInfo.cpp @@ -135,7 +135,7 @@ void CallStackTrie::addCallStack(MDNode *MIB) { assert(StackMD); std::vector CallStack; CallStack.reserve(StackMD->getNumOperands()); - for (auto &MIBStackIter : StackMD->operands()) { + for (const auto &MIBStackIter : StackMD->operands()) { auto *StackId = mdconst::dyn_extract(MIBStackIter); assert(StackId); CallStack.push_back(StackId->getZExtValue()); diff --git a/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp b/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp index 5d27c9f29984e..6507132cb3ecb 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp @@ -335,7 +335,7 @@ Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, MemberFunctionRecord &MF) { Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, MethodOverloadListRecord &MethodList) { - for (auto &M : MethodList.getMethods()) { + for (const auto &M : MethodList.getMethods()) { ListScope S(*W, "Method"); printMemberAttributes(M.getAccess(), M.getMethodKind(), M.getOptions()); printTypeIndex("Type", M.getType()); diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp index 45a5bdb48f01a..c0245dc17cf1e 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp @@ -178,7 +178,7 @@ Error PDBStringTableBuilder::writeHashTable(BinaryStreamWriter &Writer) const { return EC; std::vector Buckets(BucketCount); - for (auto &Pair : Strings) { + for (const auto &Pair : Strings) { StringRef S = Pair.getKey(); uint32_t Offset = Pair.getValue(); uint32_t Hash = hashStringV1(S); diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp index 6dfd5548fcfdb..be40b740a5a7f 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp @@ -204,7 +204,7 @@ class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder { LLVM_DEBUG(dbgs() << "Processing relocations:\n"); - for (auto &S : Obj.sections()) { + for (const auto &S : Obj.sections()) { orc::ExecutorAddr SectionAddress(S.getAddress()); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h index a5bc181f8af9f..3940e6ea5b057 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h @@ -527,7 +527,7 @@ class RuntimeDyldImpl { std::map getSymbolTable() const { std::map Result; - for (auto &KV : GlobalSymbolTable) { + for (const auto &KV : GlobalSymbolTable) { auto SectionID = KV.second.getSectionID(); uint64_t SectionAddr = getSectionLoadAddress(SectionID); Result[KV.first()] = diff --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp index b22c02d4e1fb9..e77cc70352d56 100644 --- a/llvm/lib/MC/MCWin64EH.cpp +++ b/llvm/lib/MC/MCWin64EH.cpp @@ -2360,7 +2360,7 @@ static void ARM64EmitRuntimeFunction(MCStreamer &streamer, MCContext &context = streamer.getContext(); streamer.emitValueToAlignment(4); - for (auto &S : info->Segments) { + for (const auto &S : info->Segments) { EmitSymbolRefWithOfs(streamer, info->Begin, S.Offset); if (info->PackedInfo) streamer.emitInt32(info->PackedInfo); diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp index d53cc2f7e37ba..e8742163d5658 100644 --- a/llvm/lib/MC/SubtargetFeature.cpp +++ b/llvm/lib/MC/SubtargetFeature.cpp @@ -52,7 +52,7 @@ std::string SubtargetFeatures::getString() const { } void SubtargetFeatures::print(raw_ostream &OS) const { - for (auto &F : Features) + for (const auto &F : Features) OS << F << " "; OS << "\n"; } diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp index 3be9a9c6b587c..a5b5be59ac77b 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp @@ -208,7 +208,7 @@ bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA, } const MemoryPhi *Phi = cast(MA); - for (auto &Use : Phi->incoming_values()) + for (const auto &Use : Phi->incoming_values()) WorkList.push_back(cast(&Use)); } diff --git a/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp b/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp index 56ee3cd60c171..dbb22875939e4 100644 --- a/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp +++ b/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp @@ -73,7 +73,7 @@ void HexagonBlockRanges::IndexRange::merge(const IndexRange &A) { } void HexagonBlockRanges::RangeList::include(const RangeList &RL) { - for (auto &R : RL) + for (const auto &R : RL) if (!is_contained(*this, R)) push_back(R); } @@ -175,7 +175,7 @@ MachineInstr *HexagonBlockRanges::InstrIndexMap::getInstr(IndexType Idx) const { HexagonBlockRanges::IndexType HexagonBlockRanges::InstrIndexMap::getIndex( MachineInstr *MI) const { - for (auto &I : Map) + for (const auto &I : Map) if (I.second == MI) return I.first; return IndexType::None; @@ -512,7 +512,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, raw_ostream &llvm::operator<<(raw_ostream &OS, const HexagonBlockRanges::RangeList &RL) { - for (auto &R : RL) + for (const auto &R : RL) OS << R << " "; return OS; } @@ -528,7 +528,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, raw_ostream &llvm::operator<<(raw_ostream &OS, const HexagonBlockRanges::PrintRangeMap &P) { - for (auto &I : P.Map) { + for (const auto &I : P.Map) { const HexagonBlockRanges::RangeList &RL = I.second; OS << printReg(I.first.Reg, &P.TRI, I.first.Sub) << " -> " << RL << "\n"; } diff --git a/llvm/lib/Transforms/Coroutines/CoroElide.cpp b/llvm/lib/Transforms/Coroutines/CoroElide.cpp index 6f78fc8db311a..9916de0d0b93a 100644 --- a/llvm/lib/Transforms/Coroutines/CoroElide.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroElide.cpp @@ -244,7 +244,7 @@ bool Lowerer::shouldElide(Function *F, DominatorTree &DT) const { // Filter out the coro.destroy that lie along exceptional paths. SmallPtrSet ReferencedCoroBegins; - for (auto &It : DestroyAddr) { + for (const auto &It : DestroyAddr) { // If there is any coro.destroy dominates all of the terminators for the // coro.begin, we could know the corresponding coro.begin wouldn't escape. for (Instruction *DA : It.second) { diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp index 73af30ece47c9..77bc377f45149 100644 --- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp +++ b/llvm/lib/Transforms/IPO/ConstantMerge.cpp @@ -80,7 +80,7 @@ static void copyDebugLocMetadata(const GlobalVariable *From, GlobalVariable *To) { SmallVector MDs; From->getDebugInfo(MDs); - for (auto MD : MDs) + for (auto *MD : MDs) To->addDebugInfo(MD); } diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 360ec24a05093..b589ec798caa1 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -274,7 +274,7 @@ static void computeImportForReferencedGlobals( SmallVectorImpl &Worklist, FunctionImporter::ImportMapTy &ImportList, StringMap *ExportLists) { - for (auto &VI : Summary.refs()) { + for (const auto &VI : Summary.refs()) { if (!shouldImportGlobal(VI, DefinedGVSummaries)) { LLVM_DEBUG( dbgs() << "Ref ignored! Target already in destination module.\n"); @@ -294,7 +294,7 @@ static void computeImportForReferencedGlobals( RefSummary->modulePath() != Summary.modulePath(); }; - for (auto &RefSummary : VI.getSummaryList()) + for (const auto &RefSummary : VI.getSummaryList()) if (isa(RefSummary.get()) && Index.canImportGlobalVar(RefSummary.get(), /* AnalyzeRefs */ true) && !LocalNotInModule(RefSummary.get())) { @@ -355,7 +355,7 @@ static void computeImportForFunction( computeImportForReferencedGlobals(Summary, Index, DefinedGVSummaries, Worklist, ImportList, ExportLists); static int ImportCount = 0; - for (auto &Edge : Summary.calls()) { + for (const auto &Edge : Summary.calls()) { ValueInfo VI = Edge.first; LLVM_DEBUG(dbgs() << " edge -> " << VI << " Threshold:" << Threshold << "\n"); @@ -529,7 +529,7 @@ static void ComputeImportForModule( // Populate the worklist with the import for the functions in the current // module - for (auto &GVSummary : DefinedGVSummaries) { + for (const auto &GVSummary : DefinedGVSummaries) { #ifndef NDEBUG // FIXME: Change the GVSummaryMapTy to hold ValueInfo instead of GUID // so this map look up (and possibly others) can be avoided. @@ -656,7 +656,7 @@ void llvm::ComputeCrossModuleImport( StringMap &ImportLists, StringMap &ExportLists) { // For each module that has function defined, compute the import/export lists. - for (auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) { + for (const auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) { auto &ImportList = ImportLists[DefinedGVSummaries.first()]; LLVM_DEBUG(dbgs() << "Computing import for Module '" << DefinedGVSummaries.first() << "'\n"); @@ -697,9 +697,9 @@ void llvm::ComputeCrossModuleImport( NewExports.insert(VI); } else { auto *FS = cast(S); - for (auto &Edge : FS->calls()) + for (const auto &Edge : FS->calls()) NewExports.insert(Edge.first); - for (auto &Ref : FS->refs()) + for (const auto &Ref : FS->refs()) NewExports.insert(Ref); } } @@ -780,7 +780,7 @@ void llvm::ComputeCrossModuleImportForModule( void llvm::ComputeCrossModuleImportForModuleFromIndex( StringRef ModulePath, const ModuleSummaryIndex &Index, FunctionImporter::ImportMapTy &ImportList) { - for (auto &GlobalList : Index) { + for (const auto &GlobalList : Index) { // Ignore entries for undefined references. if (GlobalList.second.SummaryList.empty()) continue; @@ -837,7 +837,7 @@ void updateValueInfoForIndirectCalls(ModuleSummaryIndex &Index, void llvm::updateIndirectCalls(ModuleSummaryIndex &Index) { for (const auto &Entry : Index) { - for (auto &S : Entry.second.SummaryList) { + for (const auto &S : Entry.second.SummaryList) { if (auto *FS = dyn_cast(S.get())) updateValueInfoForIndirectCalls(Index, FS); } @@ -863,14 +863,14 @@ void llvm::computeDeadSymbolsAndUpdateIndirectCalls( ValueInfo VI = Index.getValueInfo(GUID); if (!VI) continue; - for (auto &S : VI.getSummaryList()) + for (const auto &S : VI.getSummaryList()) S->setLive(true); } // Add values flagged in the index as live roots to the worklist. for (const auto &Entry : Index) { auto VI = Index.getValueInfo(Entry); - for (auto &S : Entry.second.SummaryList) { + for (const auto &S : Entry.second.SummaryList) { if (auto *FS = dyn_cast(S.get())) updateValueInfoForIndirectCalls(Index, FS); if (S->isLive()) { @@ -907,7 +907,7 @@ void llvm::computeDeadSymbolsAndUpdateIndirectCalls( if (isPrevailing(VI.getGUID()) == PrevailingType::No) { bool KeepAliveLinkage = false; bool Interposable = false; - for (auto &S : VI.getSummaryList()) { + for (const auto &S : VI.getSummaryList()) { if (S->linkage() == GlobalValue::AvailableExternallyLinkage || S->linkage() == GlobalValue::WeakODRLinkage || S->linkage() == GlobalValue::LinkOnceODRLinkage) @@ -927,7 +927,7 @@ void llvm::computeDeadSymbolsAndUpdateIndirectCalls( } } - for (auto &S : VI.getSummaryList()) + for (const auto &S : VI.getSummaryList()) S->setLive(true); ++LiveSymbols; Worklist.push_back(VI); @@ -935,7 +935,7 @@ void llvm::computeDeadSymbolsAndUpdateIndirectCalls( while (!Worklist.empty()) { auto VI = Worklist.pop_back_val(); - for (auto &Summary : VI.getSummaryList()) { + for (const auto &Summary : VI.getSummaryList()) { if (auto *AS = dyn_cast(Summary.get())) { // If this is an alias, visit the aliasee VI to ensure that all copies // are marked live and it is added to the worklist for further @@ -982,12 +982,12 @@ void llvm::gatherImportedSummariesForModule( ModuleToSummariesForIndex[std::string(ModulePath)] = ModuleToDefinedGVSummaries.lookup(ModulePath); // Include summaries for imports. - for (auto &ILI : ImportList) { + for (const auto &ILI : ImportList) { auto &SummariesForIndex = ModuleToSummariesForIndex[std::string(ILI.first())]; const auto &DefinedGVSummaries = ModuleToDefinedGVSummaries.lookup(ILI.first()); - for (auto &GI : ILI.second) { + for (const auto &GI : ILI.second) { const auto &DS = DefinedGVSummaries.find(GI); assert(DS != DefinedGVSummaries.end() && "Expected a defined summary for imported global value"); @@ -1004,7 +1004,7 @@ std::error_code llvm::EmitImportsFiles( raw_fd_ostream ImportsOS(OutputFilename, EC, sys::fs::OpenFlags::OF_None); if (EC) return EC; - for (auto &ILI : ModuleToSummariesForIndex) + for (const auto &ILI : ModuleToSummariesForIndex) // The ModuleToSummariesForIndex map includes an entry for the current // Module (needed for writing out the index files). We don't want to // include it in the imports file, however, so filter it out. @@ -1226,10 +1226,10 @@ Expected FunctionImporter::importFunctions( IRMover Mover(DestModule); // Do the actual import of functions now, one Module at a time std::set ModuleNameOrderedList; - for (auto &FunctionsToImportPerModule : ImportList) { + for (const auto &FunctionsToImportPerModule : ImportList) { ModuleNameOrderedList.insert(FunctionsToImportPerModule.first()); } - for (auto &Name : ModuleNameOrderedList) { + for (const auto &Name : ModuleNameOrderedList) { // Get the module for the import const auto &FunctionsToImportPerModule = ImportList.find(Name); assert(FunctionsToImportPerModule != ImportList.end()); diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index f35827220bb6e..f66b872e937d6 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp @@ -206,7 +206,7 @@ void GlobalDCEPass::ScanVTables(Module &M) { void GlobalDCEPass::ScanVTableLoad(Function *Caller, Metadata *TypeId, uint64_t CallOffset) { - for (auto &VTableInfo : TypeIdMap[TypeId]) { + for (const auto &VTableInfo : TypeIdMap[TypeId]) { GlobalVariable *VTable = VTableInfo.first; uint64_t VTableOffset = VTableInfo.second; @@ -254,7 +254,7 @@ void GlobalDCEPass::ScanTypeCheckedLoadIntrinsics(Module &M) { } else { // type.checked.load with a non-constant offset, so assume every entry in // every matching vtable is used. - for (auto &VTableInfo : TypeIdMap[TypeId]) { + for (const auto &VTableInfo : TypeIdMap[TypeId]) { VFESafeVTables.erase(VTableInfo.first); } } diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index e0836a9fd6990..04d4351e16b04 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -164,7 +164,7 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) { if (skipSCC(SCC)) return false; SetVector Functions; - for (auto &N : SCC) { + for (const auto &N : SCC) { if (auto *F = N->getFunction()) Functions.insert(F); } diff --git a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp index 764fd57d245ff..4cd360ff65a3c 100644 --- a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp +++ b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp @@ -534,7 +534,7 @@ SampleContextTracker::getOrCreateContextPath(const SampleContext &Context, ContextTrieNode *ContextNode = &RootContext; LineLocation CallSiteLoc(0, 0); - for (auto &Callsite : Context.getContextFrames()) { + for (const auto &Callsite : Context.getContextFrames()) { // Create child node at parent line/disc location if (AllowCreate) { ContextNode = diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 5939fe18fc647..ad5de17107eb1 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -595,8 +595,8 @@ static bool functionHasLines(const Function &F, unsigned &EndLine) { // Check whether this function actually has any source lines. Not only // do these waste space, they also can crash gcov. EndLine = 0; - for (auto &BB : F) { - for (auto &I : BB) { + for (const auto &BB : F) { + for (const auto &I : BB) { // Debug intrinsic locations correspond to the location of the // declaration, not necessarily any statements or expressions. if (isa(&I)) continue; @@ -648,7 +648,7 @@ bool GCOVProfiler::AddFlushBeforeForkAndExec() { } } - for (auto F : Forks) { + for (auto *F : Forks) { IRBuilder<> Builder(F); BasicBlock *Parent = F->getParent(); auto NextInst = ++F->getIterator(); @@ -673,7 +673,7 @@ bool GCOVProfiler::AddFlushBeforeForkAndExec() { Parent->back().setDebugLoc(Loc); } - for (auto E : Execs) { + for (auto *E : Execs) { IRBuilder<> Builder(E); BasicBlock *Parent = E->getParent(); auto NextInst = ++E->getIterator(); @@ -879,7 +879,7 @@ bool GCOVProfiler::emitProfileNotes( while ((Idx >>= 8) > 0); } - for (auto &I : BB) { + for (const auto &I : BB) { // Debug intrinsic locations correspond to the location of the // declaration, not necessarily any statements or expressions. if (isa(&I)) continue; diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index bceb3fc2c8d4f..2ffa4ee942f81 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -1495,7 +1495,7 @@ bool HWAddressSanitizer::sanitizeFunction(Function &F, instrumentMemAccess(Operand); if (ClInstrumentMemIntrinsics && !IntrinToInstrument.empty()) { - for (auto Inst : IntrinToInstrument) + for (auto *Inst : IntrinToInstrument) instrumentMemIntrinsic(cast(Inst)); } diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp index 3ef06907dfee7..b66e761d53b0c 100644 --- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -281,7 +281,7 @@ uint32_t ICallPromotionFunc::tryToPromote( uint64_t &TotalCount) { uint32_t NumPromoted = 0; - for (auto &C : Candidates) { + for (const auto &C : Candidates) { uint64_t Count = C.Count; pgo::promoteIndirectCall(CB, C.TargetFunction, Count, TotalCount, SamplePGO, &ORE); diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp index 772a1d89e4e92..378dd96e10301 100644 --- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -561,12 +561,12 @@ bool ThreadSanitizer::sanitizeFunction(Function &F, // Instrument atomic memory accesses in any case (they can be used to // implement synchronization). if (ClInstrumentAtomics) - for (auto Inst : AtomicAccesses) { + for (auto *Inst : AtomicAccesses) { Res |= instrumentAtomic(Inst, DL); } if (ClInstrumentMemIntrinsics && SanitizeFunction) - for (auto Inst : MemIntrinCalls) { + for (auto *Inst : MemIntrinCalls) { Res |= instrumentMemIntrinsic(Inst); } diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp index fe6f9486ab0cf..73e2407fa84e0 100644 --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -221,7 +221,7 @@ static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI, // dominated by any other blocks in set 'BBs', and all nodes in the path // in the dominator tree from Entry to 'BB'. SmallPtrSet Candidates; - for (auto BB : BBs) { + for (auto *BB : BBs) { // Ignore unreachable basic blocks. if (!DT.isReachableFromEntry(BB)) continue; @@ -330,7 +330,7 @@ SetVector ConstantHoistingPass::findConstantInsertionPoint( if (BFI) { findBestInsertionSet(*DT, *BFI, Entry, BBs); - for (auto BB : BBs) { + for (auto *BB : BBs) { BasicBlock::iterator InsertPt = BB->begin(); for (; isa(InsertPt) || InsertPt->isEHPad(); ++InsertPt) ; diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp index cf28249541227..fd4882e2531e0 100644 --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -1106,7 +1106,7 @@ bool EarlyCSE::handleBranchCondition(Instruction *CondInst, Value *LHS, *RHS; if (MatchBinOp(Curr, PropagateOpcode, LHS, RHS)) - for (auto &Op : { LHS, RHS }) + for (auto *Op : { LHS, RHS }) if (Instruction *OPI = dyn_cast(Op)) if (SimpleValue::canHandle(OPI) && Visited.insert(OPI).second) WorkList.push_back(OPI); diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 0113e7bf570df..3fc078a05e32f 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -2438,7 +2438,7 @@ BasicBlock *JumpThreadingPass::splitBlockPreds(BasicBlock *BB, // update the edge weight of the result of splitting predecessors. DenseMap FreqMap; if (HasProfileData) - for (auto Pred : Preds) + for (auto *Pred : Preds) FreqMap.insert(std::make_pair( Pred, BFI->getBlockFreq(Pred) * BPI->getEdgeProbability(Pred, BB))); @@ -2453,7 +2453,7 @@ BasicBlock *JumpThreadingPass::splitBlockPreds(BasicBlock *BB, std::vector Updates; Updates.reserve((2 * Preds.size()) + NewBBs.size()); - for (auto NewBB : NewBBs) { + for (auto *NewBB : NewBBs) { BlockFrequency NewBBFreq(0); Updates.push_back({DominatorTree::Insert, NewBB, BB}); for (auto Pred : predecessors(NewBB)) { diff --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp index 88fad9896c59e..605c3520bbf90 100644 --- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp @@ -164,7 +164,7 @@ static void handlePhiDef(CallInst *Expect) { // Executes the recorded operations on input 'Value'. auto ApplyOperations = [&](const APInt &Value) { APInt Result = Value; - for (auto Op : llvm::reverse(Operations)) { + for (auto *Op : llvm::reverse(Operations)) { switch (Op->getOpcode()) { case Instruction::Xor: Result ^= cast(Op->getOperand(1))->getValue(); diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index cd2ce8ce336e5..b467bc2244c5c 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -2027,7 +2027,7 @@ void ReassociatePass::RecursivelyEraseDeadInsts(Instruction *I, RedoInsts.remove(I); llvm::salvageDebugInfo(*I); I->eraseFromParent(); - for (auto Op : Ops) + for (auto *Op : Ops) if (Instruction *OpInst = dyn_cast(Op)) if (OpInst->use_empty()) Insts.insert(OpInst); diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 2282ef6360767..6d98eb4c12d04 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -705,7 +705,7 @@ bool llvm::runIPSCCP( // If we inferred constant or undef values for globals variables, we can // delete the global and any stores that remain to it. - for (auto &I : make_early_inc_range(Solver.getTrackedGlobals())) { + for (const auto &I : make_early_inc_range(Solver.getTrackedGlobals())) { GlobalVariable *GV = I.first; if (isOverdefined(I.second)) continue; diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp index 0b797abefe207..ee7fd0e402e38 100644 --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -395,7 +395,7 @@ void StructurizeCFG::orderNodes() { WorkList.emplace_back(I, I + Size); // Add the SCC nodes to the Order array. - for (auto &N : SCC) { + for (const auto &N : SCC) { assert(I < E && "SCC size mismatch!"); Order[I++] = N.first; } diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index e3cb5f359e346..81f1fa1b5199a 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -1592,7 +1592,7 @@ static void reconnectPhis(BasicBlock *Out, BasicBlock *GuardBlock, auto NewPhi = PHINode::Create(Phi->getType(), Incoming.size(), Phi->getName() + ".moved", &FirstGuardBlock->back()); - for (auto In : Incoming) { + for (auto *In : Incoming) { Value *V = UndefValue::get(Phi->getType()); if (In == Out) { V = NewPhi; @@ -1686,7 +1686,7 @@ static void convertToGuardPredicates( GuardPredicates[Out] = Phi; } - for (auto In : Incoming) { + for (auto *In : Incoming) { Value *Condition; BasicBlock *Succ0; BasicBlock *Succ1; @@ -1771,9 +1771,9 @@ BasicBlock *llvm::CreateControlFlowHub( SmallVector Updates; if (DTU) { - for (auto In : Incoming) { + for (auto *In : Incoming) { Updates.push_back({DominatorTree::Insert, In, FirstGuardBlock}); - for (auto Succ : successors(In)) { + for (auto *Succ : successors(In)) { if (Outgoing.count(Succ)) Updates.push_back({DominatorTree::Delete, In, Succ}); } diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 1d348213bfdbd..d20d2a2d77d0c 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -1041,7 +1041,7 @@ void llvm::cloneNoAliasScopes(ArrayRef NoAliasDeclScopes, MDBuilder MDB(Context); for (auto *ScopeList : NoAliasDeclScopes) { - for (auto &MDOperand : ScopeList->operands()) { + for (const auto &MDOperand : ScopeList->operands()) { if (MDNode *MD = dyn_cast(MDOperand)) { AliasScopeNode SNANode(MD); @@ -1066,7 +1066,7 @@ void llvm::adaptNoAliasScopes(Instruction *I, auto CloneScopeList = [&](const MDNode *ScopeList) -> MDNode * { bool NeedsReplacement = false; SmallVector NewScopeList; - for (auto &MDOp : ScopeList->operands()) { + for (const auto &MDOp : ScopeList->operands()) { if (MDNode *MD = dyn_cast(MDOp)) { if (auto *NewMD = ClonedScopes.lookup(MD)) { NewScopeList.push_back(NewMD); diff --git a/llvm/lib/Transforms/Utils/FixIrreducible.cpp b/llvm/lib/Transforms/Utils/FixIrreducible.cpp index 24539bd231c6d..2cda72ecf9d2f 100644 --- a/llvm/lib/Transforms/Utils/FixIrreducible.cpp +++ b/llvm/lib/Transforms/Utils/FixIrreducible.cpp @@ -146,7 +146,7 @@ static void reconnectChildLoops(LoopInfo &LI, Loop *ParentLoop, Loop *NewLoop, } std::vector GrandChildLoops; std::swap(GrandChildLoops, Child->getSubLoopsVector()); - for (auto GrandChildLoop : GrandChildLoops) { + for (auto *GrandChildLoop : GrandChildLoops) { GrandChildLoop->setParentLoop(nullptr); NewLoop->addChildLoop(GrandChildLoop); } @@ -170,14 +170,14 @@ static void createNaturalLoopInternal(LoopInfo &LI, DominatorTree &DT, SetVector &Headers) { #ifndef NDEBUG // All headers are part of the SCC - for (auto H : Headers) { + for (auto *H : Headers) { assert(Blocks.count(H)); } #endif SetVector Predecessors; - for (auto H : Headers) { - for (auto P : predecessors(H)) { + for (auto *H : Headers) { + for (auto *P : predecessors(H)) { Predecessors.insert(P); } } @@ -214,13 +214,13 @@ static void createNaturalLoopInternal(LoopInfo &LI, DominatorTree &DT, // in the loop. This ensures that it is recognized as the // header. Since the new loop is already in LoopInfo, the new blocks // are also propagated up the chain of parent loops. - for (auto G : GuardBlocks) { + for (auto *G : GuardBlocks) { LLVM_DEBUG(dbgs() << "added guard block: " << G->getName() << "\n"); NewLoop->addBasicBlockToLoop(G, LI); } // Add the SCC blocks to the new loop. - for (auto BB : Blocks) { + for (auto *BB : Blocks) { NewLoop->addBlockEntry(BB); if (LI.getLoopFor(BB) == ParentLoop) { LLVM_DEBUG(dbgs() << "moved block from parent: " << BB->getName() @@ -288,7 +288,7 @@ static bool makeReducible(LoopInfo &LI, DominatorTree &DT, Graph &&G) { // match. So we discover the headers using the reverse of the block order. SetVector Headers; LLVM_DEBUG(dbgs() << "Found headers:"); - for (auto BB : reverse(Blocks)) { + for (auto *BB : reverse(Blocks)) { for (const auto P : predecessors(BB)) { // Skip unreachable predecessors. if (!DT.isReachableFromEntry(P)) diff --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp index 06596f7b04e17..a548c4e241a6e 100644 --- a/llvm/lib/Transforms/Utils/FunctionComparator.cpp +++ b/llvm/lib/Transforms/Utils/FunctionComparator.cpp @@ -968,7 +968,7 @@ FunctionComparator::FunctionHash FunctionComparator::functionHash(Function &F) { // This random value acts as a block header, as otherwise the partition of // opcodes into BBs wouldn't affect the hash, only the order of the opcodes H.add(45798); - for (auto &Inst : *BB) { + for (const auto &Inst : *BB) { H.add(Inst.getOpcode()); } const Instruction *Term = BB->getTerminator(); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 03272e5f8a549..dca62dfaf36ca 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1676,7 +1676,7 @@ Value *llvm::addDiffRuntimeChecks( // Our instructions might fold to a constant. Value *MemoryRuntimeCheck = nullptr; - for (auto &C : Checks) { + for (const auto &C : Checks) { Type *Ty = C.SinkStart->getType(); // Compute VF * IC * AccessSize. auto *VFTimesUFTimesSize = diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp index 53334bc2a3693..de11b42eb9635 100644 --- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp +++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp @@ -626,7 +626,7 @@ void PredicateInfoBuilder::renameUses(SmallVectorImpl &OpsToRename) { // Insert the possible copies into the def/use list. // They will become real copies if we find a real use for them, and never // created otherwise. - for (auto &PossibleCopy : ValueInfo.Infos) { + for (const auto &PossibleCopy : ValueInfo.Infos) { ValueDFS VD; // Determine where we are going to place the copy by the copy type. // The predicate info for branches always come first, they will get @@ -772,7 +772,7 @@ PredicateInfo::~PredicateInfo() { // Collect function pointers in set first, as SmallSet uses a SmallVector // internally and we have to remove the asserting value handles first. SmallPtrSet FunctionPtrs; - for (auto &F : CreatedDeclarations) + for (const auto &F : CreatedDeclarations) FunctionPtrs.insert(&*F); CreatedDeclarations.clear(); diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp index 02f4c84939030..62894b9fb2b44 100644 --- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -499,7 +499,7 @@ static void dumpCXXData(const ObjectFile *Obj) { static void dumpArchive(const Archive *Arc) { Error Err = Error::success(); - for (auto &ArcC : Arc->children(Err)) { + for (const auto &ArcC : Arc->children(Err)) { Expected> ChildOrErr = ArcC.getAsBinary(); if (!ChildOrErr) { // Ignore non-object files. diff --git a/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp b/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp index 1ade7f3970308..c42028375b23d 100644 --- a/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp +++ b/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp @@ -36,16 +36,16 @@ bool PrettyClassLayoutGraphicalDumper::start(const UDTLayoutBase &Layout) { if (RecursionLevel == 1 && opts::pretty::ClassFormat == opts::pretty::ClassDefinitionFormat::All) { - for (auto &Other : Layout.other_items()) + for (const auto &Other : Layout.other_items()) Other->dump(*this); - for (auto &Func : Layout.funcs()) + for (const auto &Func : Layout.funcs()) Func->dump(*this); } const BitVector &UseMap = Layout.usedBytes(); int NextPaddingByte = UseMap.find_first_unset(); - for (auto &Item : Layout.layout_items()) { + for (const auto &Item : Layout.layout_items()) { // Calculate the absolute offset of the first byte of the next field. uint32_t RelativeOffset = Item->getOffsetInParent(); CurrentAbsoluteOffset = ClassOffsetZero + RelativeOffset; diff --git a/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp b/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp index 7deeaef40cafc..a9ff5a204ff22 100644 --- a/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp +++ b/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp @@ -173,7 +173,7 @@ void SDKNameMap::populateFromObject(ObjectFile *O) { } const auto *ELF = cast(O); - for (auto &S : ELF->getDynamicSymbolIterators()) { + for (const auto &S : ELF->getDynamicSymbolIterators()) { // We want only defined global function symbols. SymbolRef::Type Type = unwrapIgnoreError(S.getType()); uint32_t Flags = unwrapIgnoreError(S.getFlags()); @@ -191,7 +191,7 @@ void SDKNameMap::populateFromObject(ObjectFile *O) { void SDKNameMap::populateFromArchive(Archive *A) { Error Err = Error::success(); int Index = -1; - for (auto &C : A->children(Err)) { + for (const auto &C : A->children(Err)) { ++Index; Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) {