Index: test/unittests/compiler/live-range-unittest.cc |
diff --git a/test/unittests/compiler/live-range-unittest.cc b/test/unittests/compiler/live-range-unittest.cc |
index 886a8121c7c4e0f36f0da1989c07654fb1784272..e802aedff19d8cd088dda11df92aa847e2b1c8bc 100644 |
--- a/test/unittests/compiler/live-range-unittest.cc |
+++ b/test/unittests/compiler/live-range-unittest.cc |
@@ -32,11 +32,14 @@ class LiveRangeUnitTest : public TestWithZone { |
TopLevelLiveRange* Splinter(TopLevelLiveRange* top, int start, int end, |
int new_id = 0) { |
- TopLevelLiveRange* ret = |
- new (zone()) TopLevelLiveRange(new_id, MachineType::kRepTagged); |
+ if (top->splinter() == nullptr) { |
+ TopLevelLiveRange* ret = |
+ new (zone()) TopLevelLiveRange(new_id, MachineType::kRepTagged); |
+ top->SetSplinter(ret); |
+ } |
top->Splinter(LifetimePosition::FromInt(start), |
- LifetimePosition::FromInt(end), ret, zone()); |
- return ret; |
+ LifetimePosition::FromInt(end), zone()); |
+ return top->splinter(); |
} |
// Ranges first and second match structurally. |
@@ -377,6 +380,25 @@ TEST_F(LiveRangeUnitTest, SplinterMultipleIntervalsRight) { |
} |
+TEST_F(LiveRangeUnitTest, SplinterMergeMultipleTimes) { |
+ TopLevelLiveRange* range = |
+ TestRangeBuilder(zone()).Add(0, 3).Add(5, 10).Add(12, 16).Build(); |
+ Splinter(range, 4, 6); |
+ Splinter(range, 8, 14); |
+ TopLevelLiveRange* splinter = range->splinter(); |
+ EXPECT_EQ(nullptr, range->next()); |
+ EXPECT_EQ(nullptr, splinter->next()); |
+ EXPECT_EQ(range, splinter->splintered_from()); |
+ |
+ TopLevelLiveRange* expected_source = |
+ TestRangeBuilder(zone()).Add(0, 3).Add(6, 8).Add(14, 16).Build(); |
+ TopLevelLiveRange* expected_splinter = |
+ TestRangeBuilder(zone()).Add(5, 6).Add(8, 10).Add(12, 14).Build(); |
+ EXPECT_TRUE(RangesMatch(expected_source, range)); |
+ EXPECT_TRUE(RangesMatch(expected_splinter, splinter)); |
+} |
+ |
+ |
TEST_F(LiveRangeUnitTest, MergeMultipleIntervalsRight) { |
TopLevelLiveRange* original = |
TestRangeBuilder(zone()).Add(0, 3).Add(5, 8).Build(); |
@@ -416,8 +438,9 @@ TEST_F(LiveRangeUnitTest, IDGeneration) { |
TopLevelLiveRange* splinter = |
new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged); |
+ vreg->SetSplinter(splinter); |
vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12), |
- splinter, zone()); |
+ zone()); |
EXPECT_EQ(101, splinter->vreg()); |
EXPECT_EQ(1, splinter->relative_id()); |