Commit 96c0e6f9 authored by mtrofin's avatar mtrofin Committed by Commit bot

[turbofan] relative_id of splinters and their children.

A LiveRange is identified by 2 integers: the vreg() of its TopLevel,
which is the virtual register (operand) ID; and a relative_id(), which has
no meaning in the program, but is valuable in debugging or tracing
scenarios.

This change ensures that relative_id is unique even in cases of splinter
ranges and their children.

Review URL: https://codereview.chromium.org/1318493005

Cr-Commit-Position: refs/heads/master@{#30665}
parent 5b938f52
......@@ -871,6 +871,9 @@ void TopLevelLiveRange::Splinter(LifetimePosition start, LifetimePosition end,
result->top_level_ = result;
result->SetSplinteredFrom(this);
// Ensure the result's relative ID is unique within the IDs used for this
// virtual register's children and splinters.
result->relative_id_ = GetNextChildId();
}
......
......@@ -407,6 +407,7 @@ class LiveRange : public ZoneObject {
typedef BitField<int32_t, 6, 6> AssignedRegisterField;
typedef BitField<MachineType, 12, 15> MachineTypeField;
// Unique among children and splinters of the same virtual register.
int relative_id_;
uint32_t bits_;
UseInterval* last_interval_;
......@@ -535,7 +536,11 @@ class TopLevelLiveRange final : public LiveRange {
void UpdateSpillRangePostMerge(TopLevelLiveRange* merged);
int vreg() const { return vreg_; }
int GetNextChildId() { return ++last_child_id_; }
int GetNextChildId() {
return IsSplinter() ? splintered_from()->GetNextChildId()
: ++last_child_id_;
}
bool IsSpilledOnlyInDeferredBlocks() const {
return spilled_in_deferred_blocks_;
}
......
......@@ -407,6 +407,33 @@ TEST_F(LiveRangeUnitTest, MergeAfterSplitting) {
}
TEST_F(LiveRangeUnitTest, IDGeneration) {
TopLevelLiveRange* vreg = TestRangeBuilder(zone()).Id(2).Build(0, 100);
EXPECT_EQ(2, vreg->vreg());
EXPECT_EQ(0, vreg->relative_id());
TopLevelLiveRange* splinter =
new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged);
vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12),
splinter, zone());
EXPECT_EQ(101, splinter->vreg());
EXPECT_EQ(1, splinter->relative_id());
LiveRange* child = vreg->SplitAt(LifetimePosition::FromInt(50), zone());
EXPECT_EQ(2, child->relative_id());
LiveRange* splinter_child =
splinter->SplitAt(LifetimePosition::FromInt(8), zone());
EXPECT_EQ(1, splinter->relative_id());
EXPECT_EQ(3, splinter_child->relative_id());
vreg->Merge(splinter, zone());
EXPECT_EQ(1, splinter->relative_id());
}
} // namespace compiler
} // namespace internal
} // namespace v8
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