[llvm] fe35e14 - [MachineOutliner] NFC: Pull variable out from erase_if
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 3 16:41:58 PST 2023
Author: Jessica Paquette
Date: 2023-02-03T16:41:02-08:00
New Revision: fe35e142dffa4f67b0d377bb37d0fdc26aa057dd
URL: https://github.com/llvm/llvm-project/commit/fe35e142dffa4f67b0d377bb37d0fdc26aa057dd
DIFF: https://github.com/llvm/llvm-project/commit/fe35e142dffa4f67b0d377bb37d0fdc26aa057dd.diff
LOG: [MachineOutliner] NFC: Pull variable out from erase_if
`Mapper.UnsignedVec.begin()` never changes throughout the call to
`erase_if`, so no need to recalculate it.
Also drop some redundant braces.
Added:
Modified:
llvm/lib/CodeGen/MachineOutliner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 7282a4c13c2f..0dd5ab7ea8e1 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -800,14 +800,15 @@ bool MachineOutliner::outline(Module &M,
// Walk over each function, outlining them as we go along. Functions are
// outlined greedily, based off the sort above.
+ auto *UnsignedVecBegin = Mapper.UnsignedVec.begin();
for (OutlinedFunction &OF : FunctionList) {
// If we outlined something that overlapped with a candidate in a previous
// step, then we can't outline from it.
- erase_if(OF.Candidates, [&Mapper](Candidate &C) {
- return std::any_of(
- Mapper.UnsignedVec.begin() + C.getStartIdx(),
- Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
- [](unsigned I) { return (I == static_cast<unsigned>(-1)); });
+ erase_if(OF.Candidates, [&UnsignedVecBegin](Candidate &C) {
+ return std::any_of(UnsignedVecBegin + C.getStartIdx(),
+ UnsignedVecBegin + C.getEndIdx() + 1, [](unsigned I) {
+ return I == static_cast<unsigned>(-1);
+ });
});
// If we made it unbeneficial to outline this function, skip it.
@@ -898,9 +899,8 @@ bool MachineOutliner::outline(Module &M,
MBB.erase(std::next(StartIt), std::next(EndIt));
// Keep track of what we removed by marking them all as -1.
- for (unsigned &I :
- make_range(Mapper.UnsignedVec.begin() + C.getStartIdx(),
- Mapper.UnsignedVec.begin() + C.getEndIdx() + 1))
+ for (unsigned &I : make_range(UnsignedVecBegin + C.getStartIdx(),
+ UnsignedVecBegin + C.getEndIdx() + 1))
I = static_cast<unsigned>(-1);
OutlinedSomething = true;
More information about the llvm-commits
mailing list