Commit d940690b authored by mtrofin's avatar mtrofin Committed by Commit bot

[turbofan] Live Range unit tests.

Unit tests for split/splinter/merge.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#30475}
parent 30ae0417
...@@ -437,6 +437,7 @@ LiveRange* LiveRange::SplitAt(LifetimePosition position, Zone* zone) { ...@@ -437,6 +437,7 @@ LiveRange* LiveRange::SplitAt(LifetimePosition position, Zone* zone) {
void LiveRange::DetachAt(LifetimePosition position, LiveRange* result, void LiveRange::DetachAt(LifetimePosition position, LiveRange* result,
Zone* zone) { Zone* zone) {
DCHECK(Start() < position); DCHECK(Start() < position);
DCHECK(End() > position);
DCHECK(result->IsEmpty()); DCHECK(result->IsEmpty());
// Find the last interval that ends before the position. If the // Find the last interval that ends before the position. If the
// position is contained in one of the intervals in the chain, we // position is contained in one of the intervals in the chain, we
...@@ -878,7 +879,7 @@ void TopLevelLiveRange::SetSplinteredFrom(TopLevelLiveRange* splinter_parent) { ...@@ -878,7 +879,7 @@ void TopLevelLiveRange::SetSplinteredFrom(TopLevelLiveRange* splinter_parent) {
DCHECK(splinter_parent->Start() < Start()); DCHECK(splinter_parent->Start() < Start());
splintered_from_ = splinter_parent; splintered_from_ = splinter_parent;
if (!HasSpillOperand()) { if (!HasSpillOperand() && splinter_parent->spill_range_ != nullptr) {
SetSpillRange(splinter_parent->spill_range_); SetSpillRange(splinter_parent->spill_range_);
} }
} }
......
...@@ -17,7 +17,8 @@ namespace compiler { ...@@ -17,7 +17,8 @@ namespace compiler {
// support for C++ features such as instantiation lists, on OS X and Android. // support for C++ features such as instantiation lists, on OS X and Android.
class TestRangeBuilder { class TestRangeBuilder {
public: public:
explicit TestRangeBuilder(Zone* zone) : id_(-1), pairs_(), zone_(zone) {} explicit TestRangeBuilder(Zone* zone)
: id_(-1), pairs_(), uses_(), zone_(zone) {}
TestRangeBuilder& Id(int id) { TestRangeBuilder& Id(int id) {
id_ = id; id_ = id;
...@@ -28,9 +29,16 @@ class TestRangeBuilder { ...@@ -28,9 +29,16 @@ class TestRangeBuilder {
return *this; return *this;
} }
LiveRange* Build(int start, int end) { return Add(start, end).Build(); } TestRangeBuilder& AddUse(int pos) {
uses_.insert(pos);
return *this;
}
LiveRange* Build() { TopLevelLiveRange* Build(int start, int end) {
return Add(start, end).Build();
}
TopLevelLiveRange* Build() {
TopLevelLiveRange* range = TopLevelLiveRange* range =
new (zone_) TopLevelLiveRange(id_, MachineType::kRepTagged); new (zone_) TopLevelLiveRange(id_, MachineType::kRepTagged);
// Traverse the provided interval specifications backwards, because that is // Traverse the provided interval specifications backwards, because that is
...@@ -42,6 +50,12 @@ class TestRangeBuilder { ...@@ -42,6 +50,12 @@ class TestRangeBuilder {
CHECK(start < end); CHECK(start < end);
range->AddUseInterval(start, end, zone_); range->AddUseInterval(start, end, zone_);
} }
for (int pos : uses_) {
UsePosition* use_position =
new (zone_) UsePosition(LifetimePosition::FromInt(pos), nullptr,
nullptr, UsePositionHintType::kNone);
range->AddUsePosition(use_position);
}
pairs_.clear(); pairs_.clear();
return range; return range;
...@@ -52,6 +66,7 @@ class TestRangeBuilder { ...@@ -52,6 +66,7 @@ class TestRangeBuilder {
typedef std::vector<Interval> IntervalList; typedef std::vector<Interval> IntervalList;
int id_; int id_;
IntervalList pairs_; IntervalList pairs_;
std::set<int> uses_;
Zone* zone_; Zone* zone_;
}; };
......
This diff is collapsed.
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
'compiler/js-type-feedback-unittest.cc', 'compiler/js-type-feedback-unittest.cc',
'compiler/linkage-tail-call-unittest.cc', 'compiler/linkage-tail-call-unittest.cc',
'compiler/liveness-analyzer-unittest.cc', 'compiler/liveness-analyzer-unittest.cc',
'compiler/live-range-unittest.cc',
'compiler/load-elimination-unittest.cc', 'compiler/load-elimination-unittest.cc',
'compiler/loop-peeling-unittest.cc', 'compiler/loop-peeling-unittest.cc',
'compiler/machine-operator-reducer-unittest.cc', 'compiler/machine-operator-reducer-unittest.cc',
......
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