aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOutliner.cpp
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2023-02-03 16:28:56 -0800
committerJessica Paquette <jpaquette@apple.com>2023-02-03 16:41:02 -0800
commitfe35e142dffa4f67b0d377bb37d0fdc26aa057dd (patch)
tree7f2a70eab4b4b37d3aea1a7354667ad749a9cb65 /llvm/lib/CodeGen/MachineOutliner.cpp
parent443c5b9fd505f5fe2df92ee27bf1d4d9e0dc4cb9 (diff)
downloadllvm-fe35e142dffa4f67b0d377bb37d0fdc26aa057dd.zip
llvm-fe35e142dffa4f67b0d377bb37d0fdc26aa057dd.tar.gz
llvm-fe35e142dffa4f67b0d377bb37d0fdc26aa057dd.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 7282a4c..0dd5ab7 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;