[llvm] 109df7f - [llvm] Qualify auto in range-based for loops (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 13 12:55:58 PDT 2022
Author: Kazu Hirata
Date: 2022-08-13T12:55:42-07:00
New Revision: 109df7f9a4a894cca7aaf60667721c32bb574c8f
URL: https://github.com/llvm/llvm-project/commit/109df7f9a4a894cca7aaf60667721c32bb574c8f
DIFF: https://github.com/llvm/llvm-project/commit/109df7f9a4a894cca7aaf60667721c32bb574c8f.diff
LOG: [llvm] Qualify auto in range-based for loops (NFC)
Identified with readability-qualified-auto.
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/Object/WindowsResource.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/ProfileData/GCOV.cpp
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
llvm/lib/Target/AMDGPU/GCNILPSched.cpp
llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
llvm/lib/Target/AMDGPU/GCNMinRegStrategy.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/ARM/ARMAsmPrinter.cpp
llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
llvm/lib/Target/TargetLoweringObjectFile.cpp
llvm/lib/Target/X86/X86VZeroUpper.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/lib/Transforms/Scalar/NewGVN.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/lib/Transforms/Utils/SplitModule.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
index 83711552ebd95..2d8add64537c3 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
@@ -253,7 +253,7 @@ void DWARFTypePrinter::appendUnqualifiedNameAfter(
if (getValOrNull(DW_AT_LLVM_ptrauth_authenticates_null_values))
optionsVec.push_back("authenticates-null-values");
std::string options;
- for (auto option : optionsVec) {
+ for (const auto *option : optionsVec) {
if (options.size())
options += ",";
options += option;
diff --git a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
index e2a0cadb6348a..d2d73b0fa9981 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
@@ -237,7 +237,7 @@ void CompileOnDemandLayer::expandPartition(GlobalValueSet &Partition) {
bool ContainsGlobalVariables = false;
std::vector<const GlobalValue *> GVsToAdd;
- for (auto *GV : Partition)
+ for (const auto *GV : Partition)
if (isa<GlobalAlias>(GV))
GVsToAdd.push_back(
cast<GlobalValue>(cast<GlobalAlias>(GV)->getAliasee()));
@@ -252,7 +252,7 @@ void CompileOnDemandLayer::expandPartition(GlobalValueSet &Partition) {
for (auto &G : M.globals())
GVsToAdd.push_back(&G);
- for (auto *GV : GVsToAdd)
+ for (const auto *GV : GVsToAdd)
Partition.insert(GV);
}
@@ -336,13 +336,13 @@ void CompileOnDemandLayer::emitPartition(
{
std::vector<const GlobalValue*> HashGVs;
HashGVs.reserve(GVsToExtract->size());
- for (auto *GV : *GVsToExtract)
+ for (const auto *GV : *GVsToExtract)
HashGVs.push_back(GV);
llvm::sort(HashGVs, [](const GlobalValue *LHS, const GlobalValue *RHS) {
return LHS->getName() < RHS->getName();
});
hash_code HC(0);
- for (auto *GV : HashGVs) {
+ for (const auto *GV : HashGVs) {
assert(GV->hasName() && "All GVs to extract should be named by now");
auto GVName = GV->getName();
HC = hash_combine(HC, hash_combine_range(GVName.begin(), GVName.end()));
diff --git a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
index c2fa4466eab66..80145b176c0e3 100644
--- a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
@@ -295,7 +295,7 @@ SpeculateQuery::ResultTy SequenceBBQuery::operator()(Function &F) {
else
SequencedBlocks = queryCFG(F, CallerBlocks);
- for (auto BB : SequencedBlocks)
+ for (const auto *BB : SequencedBlocks)
findCalles(BB, Calles);
CallerAndCalles.insert({F.getName(), std::move(Calles)});
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 24e013c562144..f8cf0ef798209 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -6075,7 +6075,7 @@ void Verifier::verifyCompileUnits() {
SmallPtrSet<const Metadata *, 2> Listed;
if (CUs)
Listed.insert(CUs->op_begin(), CUs->op_end());
- for (auto *CU : CUVisited)
+ for (const auto *CU : CUVisited)
CheckDI(Listed.count(CU), "DICompileUnit not listed in llvm.dbg.cu", CU);
CUVisited.clear();
}
@@ -6085,7 +6085,7 @@ void Verifier::verifyDeoptimizeCallingConvs() {
return;
const Function *First = DeoptimizeDeclarations[0];
- for (auto *F : makeArrayRef(DeoptimizeDeclarations).slice(1)) {
+ for (const auto *F : makeArrayRef(DeoptimizeDeclarations).slice(1)) {
Check(First->getCallingConv() == F->getCallingConv(),
"All llvm.experimental.deoptimize declarations must have the same "
"calling convention",
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index e31faf6422edd..f9b46550e0ac7 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1734,7 +1734,7 @@ IRMover::IRMover(Module &M) : Composite(M) {
// Self-map metadatas in the destination module. This is needed when
// DebugTypeODRUniquing is enabled on the LLVMContext, since metadata in the
// destination module may be reached from the source module.
- for (auto *MD : StructTypes.getVisitedMetadata()) {
+ for (const auto *MD : StructTypes.getVisitedMetadata()) {
SharedMDs[MD].reset(const_cast<MDNode *>(MD));
}
}
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 517779863089a..6a47229c7687c 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -3760,7 +3760,7 @@ bool MasmParser::emitIntegralValues(unsigned Size, unsigned *Count) {
if (checkForValidSection() || parseScalarInstList(Size, Values))
return true;
- for (auto Value : Values) {
+ for (const auto *Value : Values) {
emitIntValue(Value, Size);
}
if (Count)
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index d50f149629c3f..d90a338ebbc85 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -938,7 +938,7 @@ void WindowsResourceCOFFWriter::writeDirectoryTree() {
RelocationAddresses.resize(Data.size());
// Now write all the resource data entries.
- for (auto DataNodes : DataEntriesTreeOrder) {
+ for (const auto *DataNodes : DataEntriesTreeOrder) {
auto *Entry = reinterpret_cast<coff_resource_data_entry *>(BufferStart +
CurrentOffset);
RelocationAddresses[DataNodes->getDataIndex()] = CurrentRelativeOffset;
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index d579529a65a44..821a89d5eb874 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -878,7 +878,7 @@ PreservedCFGCheckerInstrumentation::CFG::CFG(const Function *F,
for (const auto &BB : *F) {
if (BBGuards)
BBGuards->try_emplace(intptr_t(&BB), &BB);
- for (auto *Succ : successors(&BB)) {
+ for (const auto *Succ : successors(&BB)) {
Graph[&BB][Succ]++;
if (BBGuards)
BBGuards->try_emplace(intptr_t(Succ), Succ);
diff --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index feacf40b8d0ae..76046ed980018 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -491,12 +491,12 @@ uint64_t GCOVBlock::getCyclesCount(const BlockVector &blocks) {
uint64_t count = 0, d;
for (;;) {
// Make blocks on the line traversable and try finding a cycle.
- for (auto b : blocks) {
+ for (const auto *b : blocks) {
const_cast<GCOVBlock *>(b)->traversable = true;
const_cast<GCOVBlock *>(b)->incoming = nullptr;
}
d = 0;
- for (auto block : blocks) {
+ for (const auto *block : blocks) {
auto *b = const_cast<GCOVBlock *>(block);
if (b->traversable && (d = augmentOneCycle(b, stack)) > 0)
break;
@@ -507,7 +507,7 @@ uint64_t GCOVBlock::getCyclesCount(const BlockVector &blocks) {
}
// If there is no more loop, all traversable bits should have been cleared.
// This property is needed by subsequent calls.
- for (auto b : blocks) {
+ for (const auto *b : blocks) {
assert(!b->traversable);
(void)b;
}
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 0fe286d239d4e..80bea1a567072 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -547,7 +547,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
// No matter which version is given to `g`, we always set imafd to default
// version since the we don't have clear version scheme for that on
// ISA spec.
- for (auto Ext : {"i", "m", "a", "f", "d"})
+ for (const auto *Ext : {"i", "m", "a", "f", "d"})
if (auto Version = findDefaultVersion(Ext))
ISAInfo->addExtension(Ext, Version->Major, Version->Minor);
else
diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
index f51b3534f11a4..8c88e2a8d108c 100644
--- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
@@ -2503,7 +2503,7 @@ bool AArch64FastISel::selectIndirectBr(const Instruction *I) {
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II).addReg(AddrReg);
// Make sure the CFG is up-to-date.
- for (auto *Succ : BI->successors())
+ for (const auto *Succ : BI->successors())
FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[Succ]);
return true;
diff --git a/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp b/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
index 2ef7bc83003ac..8b45109d976ae 100644
--- a/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
@@ -237,7 +237,7 @@ shouldReplaceInst(MachineFunction *MF, const MCInstrDesc *InstDesc,
SIMDInstrTable[InstID] = false;
return false;
}
- for (auto IDesc : InstDescRepl)
+ for (const auto *IDesc : InstDescRepl)
{
SCDescRepl = SchedModel.getMCSchedModel()->getSchedClassDesc(
IDesc->getSchedClass());
@@ -250,7 +250,7 @@ shouldReplaceInst(MachineFunction *MF, const MCInstrDesc *InstDesc,
// Replacement cost.
unsigned ReplCost = 0;
- for (auto IDesc :InstDescRepl)
+ for (const auto *IDesc :InstDescRepl)
ReplCost += SchedModel.computeInstrLatency(IDesc->getOpcode());
if (SchedModel.computeInstrLatency(InstDesc->getOpcode()) > ReplCost)
diff --git a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
index d7f4d4e92a701..8a35e970f0f6c 100644
--- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
+++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
@@ -306,7 +306,7 @@ DecodeStatus AArch64Disassembler::getInstruction(MCInst &MI, uint64_t &Size,
const uint8_t *Tables[] = {DecoderTable32, DecoderTableFallback32};
- for (auto Table : Tables) {
+ for (const auto *Table : Tables) {
DecodeStatus Result =
decodeInstruction(Table, MI, Insn, Address, this, STI);
diff --git a/llvm/lib/Target/AMDGPU/GCNILPSched.cpp b/llvm/lib/Target/AMDGPU/GCNILPSched.cpp
index 1eb617640c32a..8629db2e2563e 100644
--- a/llvm/lib/Target/AMDGPU/GCNILPSched.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNILPSched.cpp
@@ -303,7 +303,7 @@ GCNILPScheduler::schedule(ArrayRef<const SUnit*> BotRoots,
for (const SUnit &SU : SUnits)
CalcNodeSethiUllmanNumber(&SU, SUNumbers);
- for (auto SU : BotRoots) {
+ for (const auto *SU : BotRoots) {
AvailQueue.push_back(
*new (Alloc.Allocate()) Candidate(const_cast<SUnit*>(SU)));
}
diff --git a/llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp b/llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
index 86924667084df..22b529bee46e4 100644
--- a/llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
@@ -326,7 +326,7 @@ GCNIterativeScheduler::detachSchedule(ScheduleRef Schedule) const {
Res.push_back(FirstDbgValue);
const auto DbgB = DbgValues.begin(), DbgE = DbgValues.end();
- for (auto SU : Schedule) {
+ for (const auto *SU : Schedule) {
Res.push_back(SU->getInstr());
const auto &D = std::find_if(DbgB, DbgE, [SU](decltype(*DbgB) &P) {
return P.second == SU->getInstr();
diff --git a/llvm/lib/Target/AMDGPU/GCNMinRegStrategy.cpp b/llvm/lib/Target/AMDGPU/GCNMinRegStrategy.cpp
index e82d7362a3422..04a6f2a7f4fd5 100644
--- a/llvm/lib/Target/AMDGPU/GCNMinRegStrategy.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNMinRegStrategy.cpp
@@ -232,7 +232,7 @@ GCNMinRegScheduler::schedule(ArrayRef<const SUnit*> TopRoots,
int StepNo = 0;
- for (auto SU : TopRoots) {
+ for (const auto *SU : TopRoots) {
RQ.push_back(*new (Alloc.Allocate()) Candidate(SU, StepNo));
}
releaseSuccessors(&DAG.EntrySU, StepNo);
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index bf03730bffc50..2dd0da5cd56e1 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -12886,7 +12886,7 @@ static bool hasCFUser(const Value *V, SmallPtrSet<const Value *, 16> &Visited,
if (!Visited.insert(V).second)
return false;
bool Result = false;
- for (auto U : V->users()) {
+ for (const auto *U : V->users()) {
if (const IntrinsicInst *Intrinsic = dyn_cast<IntrinsicInst>(U)) {
if (V == U->getOperand(1)) {
switch (Intrinsic->getIntrinsicID()) {
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index ee4e54b99df67..6c8952414388f 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -124,7 +124,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Collect all globals that had their storage promoted to a constant pool.
// Functions are emitted before variables, so this accumulates promoted
// globals from all functions in PromotedGlobals.
- for (auto *GV : AFI->getGlobalsPromotedToConstantPool())
+ for (const auto *GV : AFI->getGlobalsPromotedToConstantPool())
PromotedGlobals.insert(GV);
// Calculate this function's optimization goal.
diff --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
index 2c896943d94e6..234c2080b027d 100644
--- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
@@ -2156,7 +2156,7 @@ void HexagonFrameLowering::determineCalleeSaves(MachineFunction &MF,
for (unsigned VR : NewRegs)
SpillRCs.insert(MRI.getRegClass(VR));
- for (auto *RC : SpillRCs) {
+ for (const auto *RC : SpillRCs) {
if (!needToReserveScavengingSpillSlots(MF, HRI, RC))
continue;
unsigned Num = 1;
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
index b4ef6597fa134..aad3103ba275f 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
@@ -430,7 +430,7 @@ MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
const Function *
HexagonTargetObjectFile::getLutUsedFunction(const GlobalObject *GO) const {
const Function *ReturnFn = nullptr;
- for (auto U : GO->users()) {
+ for (const auto *U : GO->users()) {
// validate each instance of user to be a live function.
auto *I = dyn_cast<Instruction>(U);
if (!I)
diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp
index 29cc2840310d7..8db68466490bd 100644
--- a/llvm/lib/Target/TargetLoweringObjectFile.cpp
+++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp
@@ -71,7 +71,7 @@ static bool isNullOrUndef(const Constant *C) {
return true;
if (!isa<ConstantAggregate>(C))
return false;
- for (auto Operand : C->operand_values()) {
+ for (const auto *Operand : C->operand_values()) {
if (!isNullOrUndef(cast<Constant>(Operand)))
return false;
}
diff --git a/llvm/lib/Target/X86/X86VZeroUpper.cpp b/llvm/lib/Target/X86/X86VZeroUpper.cpp
index 17fa942a66b23..5a3e5efeb402a 100644
--- a/llvm/lib/Target/X86/X86VZeroUpper.cpp
+++ b/llvm/lib/Target/X86/X86VZeroUpper.cpp
@@ -297,7 +297,7 @@ bool VZeroUpperInserter::runOnMachineFunction(MachineFunction &MF) {
// need to insert any VZEROUPPER instructions. This is constant-time, so it
// is cheap in the common case of no ymm/zmm use.
bool YmmOrZmmUsed = FnHasLiveInYmmOrZmm;
- for (auto *RC : {&X86::VR256RegClass, &X86::VR512_0_15RegClass}) {
+ for (const auto *RC : {&X86::VR256RegClass, &X86::VR512_0_15RegClass}) {
if (!YmmOrZmmUsed) {
for (MCPhysReg R : *RC) {
if (!MRI.reg_nodbg_empty(R)) {
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 0d9cbe10b29b9..efbc950496b69 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -473,7 +473,7 @@ static bool getPotentialCopiesOfMemoryValue(
// Only if we were successful collection all potential copies we record
// dependences (on non-fix AAPointerInfo AAs). We also only then modify the
// given PotentialCopies container.
- for (auto *PI : PIs) {
+ for (const auto *PI : PIs) {
if (!PI->getState().isAtFixpoint())
UsedAssumedInformation = true;
A.recordDependence(*PI, QueryingAA, DepClassTy::OPTIONAL);
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index b129b2d7b5070..fa4e33a820edd 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -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()
@@ -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)))
@@ -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;
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 2a48b44795288..1fd8133550b42 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -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))
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index e1a000b31cf93..da360acbbb378 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -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
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 876ef3c427a6c..955138bb511a8 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -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});
}
@@ -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);
}
@@ -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);
}
@@ -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))
@@ -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");
}
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index 48e1f9ede62fb..2da56e96c1187 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -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;
diff --git a/llvm/lib/Transforms/Utils/CodeMoverUtils.cpp b/llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
index 648f4e64a4d2a..768e216f8eed8 100644
--- a/llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
+++ b/llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
@@ -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);
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index dca62dfaf36ca..232964cd4344e 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -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);
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index d0dfbc1595b65..95e6427077915 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -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);
}
diff --git a/llvm/lib/Transforms/Utils/SplitModule.cpp b/llvm/lib/Transforms/Utils/SplitModule.cpp
index 7e12bbd2851cf..9c39c26d8b7af 100644
--- a/llvm/lib/Transforms/Utils/SplitModule.cpp
+++ b/llvm/lib/Transforms/Utils/SplitModule.cpp
@@ -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()) {
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c1d5677d16f78..91a452ef197c4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -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;
More information about the llvm-commits
mailing list