aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOutliner.cpp
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-11-12 17:50:56 +0000
committerJessica Paquette <jpaquette@apple.com>2018-11-12 17:50:56 +0000
commit970214434116e3521d91cc30827e23e6f908bb60 (patch)
treef4afdaec13417e7ed1f8b828565f61dded0248c6 /llvm/lib/CodeGen/MachineOutliner.cpp
parent3954272ac11e93a11e5e1addfbafa786d93aa892 (diff)
downloadllvm-970214434116e3521d91cc30827e23e6f908bb60.zip
llvm-970214434116e3521d91cc30827e23e6f908bb60.tar.gz
llvm-970214434116e3521d91cc30827e23e6f908bb60.tar.bz2
[MachineOutliner][NFC] Early exit pruning when candidates don't share an MBB
There's no way they can overlap in this case. This can save a few iterations when the candidate is close to the beginning of a MachineBasicBlock. It's particularly useful when the average length of a MachineBasicBlock in the program is small. llvm-svn: 346682
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 7c2635e..143310e 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -1215,12 +1215,20 @@ void MachineOutliner::pruneOverlaps(
if (C1.getStartIdx() > MaxCandidateLen)
FarthestPossibleIdx = C1.getStartIdx() - MaxCandidateLen;
+ MachineBasicBlock *C1MBB = C1.getMBB();
+
// Compare against the candidates in the list that start at most
// FarthestPossibleIdx indices away from C1. There are at most
// MaxCandidateLen of these.
for (auto Sit = It + 1; Sit != Et; Sit++) {
Candidate &C2 = **Sit;
+ // If the two candidates don't belong to the same MBB, then we're done.
+ // Because we sorted the candidates, there's no way that we'd find a
+ // candidate in C1MBB after this point.
+ if (C2.getMBB() != C1MBB)
+ break;
+
// Is this candidate too far away to overlap?
if (C2.getStartIdx() < FarthestPossibleIdx)
break;