[turbofan] More thorough validation of LiveRanges.

Added structural validation to live ranges, esp. for bugs that may
arise due to splintering / merging.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32954}
This commit is contained in:
mtrofin 2015-12-17 07:29:12 -08:00 committed by Commit bot
parent 8d00c2ca40
commit 6e8065a506
2 changed files with 45 additions and 6 deletions

View File

@ -278,7 +278,7 @@ LiveRange::LiveRange(int relative_id, MachineRepresentation rep,
}
void LiveRange::Verify() const {
void LiveRange::VerifyPositions() const {
// Walk the positions, verifying that each is in an interval.
auto interval = first_interval_;
for (auto pos = first_pos_; pos != nullptr; pos = pos->next()) {
@ -293,6 +293,18 @@ void LiveRange::Verify() const {
}
void LiveRange::VerifyIntervals() const {
DCHECK(first_interval()->start() == Start());
LifetimePosition last_end = first_interval()->end();
for (UseInterval* interval = first_interval()->next(); interval != nullptr;
interval = interval->next()) {
DCHECK(last_end <= interval->start());
last_end = interval->end();
}
DCHECK(last_end == End());
}
void LiveRange::set_assigned_register(int reg) {
DCHECK(!HasRegisterAssigned() && !spilled());
bits_ = AssignedRegisterField::update(bits_, reg);
@ -530,8 +542,8 @@ UsePosition* LiveRange::DetachAt(LifetimePosition position, LiveRange* result,
size_ = kInvalidSize;
weight_ = kInvalidWeight;
#ifdef DEBUG
Verify();
result->Verify();
VerifyChildStructure();
result->VerifyChildStructure();
#endif
return use_before;
}
@ -959,6 +971,24 @@ void TopLevelLiveRange::Merge(TopLevelLiveRange* other, Zone* zone) {
}
void TopLevelLiveRange::VerifyChildrenInOrder() const {
LifetimePosition last_end = End();
for (const LiveRange* child = this->next(); child != nullptr;
child = child->next()) {
DCHECK(last_end <= child->Start());
last_end = child->End();
}
}
void TopLevelLiveRange::Verify() const {
VerifyChildrenInOrder();
for (const LiveRange* child = this; child != nullptr; child = child->next()) {
VerifyChildStructure();
}
}
void TopLevelLiveRange::ShortenTo(LifetimePosition start) {
TRACE("Shorten live range %d to [%d\n", vreg(), start.value());
DCHECK(first_interval_ != nullptr);
@ -2153,8 +2183,8 @@ void LiveRangeBuilder::Verify() const {
for (auto& hint : phi_hints_) {
CHECK(hint.second->IsResolved());
}
for (LiveRange* current : data()->live_ranges()) {
if (current != nullptr) current->Verify();
for (TopLevelLiveRange* current : data()->live_ranges()) {
if (current != nullptr && !current->IsEmpty()) current->Verify();
}
}

View File

@ -398,7 +398,10 @@ class LiveRange : public ZoneObject {
bool Covers(LifetimePosition position) const;
LifetimePosition FirstIntersection(LiveRange* other) const;
void Verify() const;
void VerifyChildStructure() const {
VerifyIntervals();
VerifyPositions();
}
void ConvertUsesToOperand(const InstructionOperand& op,
const InstructionOperand& spill_op);
@ -431,6 +434,9 @@ class LiveRange : public ZoneObject {
void AdvanceLastProcessedMarker(UseInterval* to_start_of,
LifetimePosition but_not_past) const;
void VerifyPositions() const;
void VerifyIntervals() const;
typedef BitField<bool, 0, 1> SpilledField;
typedef BitField<int32_t, 6, 6> AssignedRegisterField;
typedef BitField<MachineRepresentation, 12, 8> RepresentationField;
@ -593,6 +599,9 @@ class TopLevelLiveRange final : public LiveRange {
int debug_virt_reg() const;
#endif
void Verify() const;
void VerifyChildrenInOrder() const;
int GetNextChildId() {
return IsSplinter() ? splintered_from()->GetNextChildId()
: ++last_child_id_;