Commit 4c220552 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[regalloc] Fix perf bug in LiveRangeBundle

Only process each LiveRangeBundle once in AssignSpillSlots().

Previously we would try to merge a LiveRangeBundle as many times as
there are LiveRanges inside it. Even though the merge would only happen
once, we would still iterate over all LiveRanges and do expensive checks
for each iteration.

R=sigurds@chromium.org

Bug: v8:11237
Change-Id: I9e613aaf5e571d4c28486dd2c20154336c533563
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2584956
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71741}
parent 366d2286
......@@ -2680,7 +2680,7 @@ LiveRangeBundle* LiveRangeBundle::TryMerge(LiveRangeBundle* lhs,
return lhs;
}
void LiveRangeBundle::MergeSpillRanges() {
void LiveRangeBundle::MergeSpillRangesAndClear() {
DCHECK_IMPLIES(ranges_.empty(), uses_.empty());
SpillRange* target = nullptr;
for (auto range : ranges_) {
......@@ -2693,6 +2693,11 @@ void LiveRangeBundle::MergeSpillRanges() {
}
}
}
// Clear the fields so that we don't try to merge the spill ranges again when
// we hit the same bundle from a different LiveRange in AssignSpillSlots.
// LiveRangeBundles are not used after this.
ranges_.clear();
uses_.clear();
}
RegisterAllocator::RegisterAllocator(TopTierRegisterAllocationData* data,
......@@ -4493,7 +4498,7 @@ void OperandAssigner::AssignSpillSlots() {
for (auto range : data()->live_ranges()) {
data()->tick_counter()->TickAndMaybeEnterSafepoint();
if (range != nullptr && range->get_bundle() != nullptr) {
range->get_bundle()->MergeSpillRanges();
range->get_bundle()->MergeSpillRangesAndClear();
}
}
ZoneVector<SpillRange*>& spill_ranges = data()->spill_ranges();
......
......@@ -727,7 +727,7 @@ struct LiveRangeOrdering {
};
class LiveRangeBundle : public ZoneObject {
public:
void MergeSpillRanges();
void MergeSpillRangesAndClear();
int id() { return id_; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment