[llvm] 6da470d - [llvm] Use range-based for loops (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 2 09:33:02 PDT 2023
Author: Kazu Hirata
Date: 2023-09-02T09:32:45-07:00
New Revision: 6da470d7f8bf1b3d2d260420e10397ffbd9689cb
URL: https://github.com/llvm/llvm-project/commit/6da470d7f8bf1b3d2d260420e10397ffbd9689cb
DIFF: https://github.com/llvm/llvm-project/commit/6da470d7f8bf1b3d2d260420e10397ffbd9689cb.diff
LOG: [llvm] Use range-based for loops (NFC)
Added:
Modified:
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
llvm/lib/TextAPI/TextStubV5.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 544581b3e1bf3c..e995293dcd47d9 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -2719,10 +2719,10 @@ bool ShuffleVectorInst::isOneUseSingleSourceMask(ArrayRef<int> Mask, int VF) {
if (all_of(SubMask, [](int Idx) { return Idx == PoisonMaskElem; }))
continue;
SmallBitVector Used(VF, false);
- for_each(SubMask, [&Used, VF](int Idx) {
+ for (int Idx : SubMask) {
if (Idx != PoisonMaskElem && Idx < VF)
Used.set(Idx);
- });
+ }
if (!Used.all())
return false;
}
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 57b5f9a2879451..14c00cd97f7b71 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -2003,10 +2003,10 @@ SmallVector<uint32_t, 8> HvxSelector::getPerfectCompletions(ShuffleMask SM,
if ((unsigned)llvm::popcount(P) < Count) {
// Reset all occurences of P, if there are more occurrences of P
// than there are bits in P.
- for_each(Worklist, [P](unsigned &Q) {
+ for (unsigned &Q : Worklist) {
if (Q == P)
Q = 0;
- });
+ }
}
}
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
index 5cd41cc39fd0fb..9e06f4689304ba 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
@@ -427,7 +427,8 @@ bool NVPTXLowerArgs::runOnKernelFunction(const NVPTXTargetMachine &TM,
auto HandleIntToPtr = [this](Value &V) {
if (llvm::all_of(V.users(), [](User *U) { return isa<IntToPtrInst>(U); })) {
SmallVector<User *, 16> UsersToUpdate(V.users());
- llvm::for_each(UsersToUpdate, [&](User *U) { markPointerAsGlobal(U); });
+ for (User *U : UsersToUpdate)
+ markPointerAsGlobal(U);
}
};
if (TM.getDrvInterface() == NVPTX::CUDA) {
diff --git a/llvm/lib/TextAPI/TextStubV5.cpp b/llvm/lib/TextAPI/TextStubV5.cpp
index 69778c52c68ece..31d7dffad306aa 100644
--- a/llvm/lib/TextAPI/TextStubV5.cpp
+++ b/llvm/lib/TextAPI/TextStubV5.cpp
@@ -754,9 +754,9 @@ std::vector<std::string> serializeTargets(const AggregateT Targets,
if (Targets.size() == ActiveTargets.size())
return TargetsStr;
- llvm::for_each(Targets, [&TargetsStr](const MachO::Target &Target) {
+ for (const MachO::Target &Target : Targets)
TargetsStr.emplace_back(getFormattedStr(Target));
- });
+
return TargetsStr;
}
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 227e1e0e74f8a7..cbf180937007b2 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1471,10 +1471,10 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo,
// llvm.type.test and therefore require an llvm.type.test resolution for the
// type identifier.
- std::for_each(CallBases.begin(), CallBases.end(), [](auto &CBs) {
- CBs.first->replaceAllUsesWith(CBs.second);
- CBs.first->eraseFromParent();
- });
+ for (auto &[Old, New] : CallBases) {
+ Old->replaceAllUsesWith(New);
+ Old->eraseFromParent();
+ }
};
Apply(SlotInfo.CSInfo);
for (auto &P : SlotInfo.ConstCSInfo)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4eb240c08ac3c6..6c25c80fe10422 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -10074,22 +10074,22 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Args &...Params) {
if (It != Scalars.end()) {
// Replace undefs by the non-poisoned scalars and emit broadcast.
int Pos = std::distance(Scalars.begin(), It);
- for_each(UndefPos, [&](int I) {
+ for (int I : UndefPos) {
// Set the undef position to the non-poisoned scalar.
ReuseMask[I] = Pos;
// Replace the undef by the poison, in the mask it is replaced by
// non-poisoned scalar already.
if (I != Pos)
Scalars[I] = PoisonValue::get(ScalarTy);
- });
+ }
} else {
// Replace undefs by the poisons, emit broadcast and then emit
// freeze.
- for_each(UndefPos, [&](int I) {
+ for (int I : UndefPos) {
ReuseMask[I] = PoisonMaskElem;
if (isa<UndefValue>(Scalars[I]))
Scalars[I] = PoisonValue::get(ScalarTy);
- });
+ }
NeedFreeze = true;
}
}
More information about the llvm-commits
mailing list