Commit e5e55c61 authored by Mircea Trofin's avatar Mircea Trofin Committed by Commit Bot

[turbofan] Flaky regalloc verifier investigation: capture caller.

Capture the place we call the verifier as part of the investigation
into the referenced bug.

Bug: chromium:725559
Change-Id: I08fa91636f73994f8d77ac6ab66aa7165a12ef0b
Reviewed-on: https://chromium-review.googlesource.com/524266
Commit-Queue: Brad Nelson <bradnelson@chromium.org>
Reviewed-by: 's avatarBrad Nelson <bradnelson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45712}
parent f5767bf6
......@@ -2043,7 +2043,7 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
// we understand the cause of the bug. We keep just the
// check at the end of the allocation.
if (verifier != nullptr) {
verifier->VerifyAssignment();
verifier->VerifyAssignment("Immediately after CommitAssignmentPhase.");
}
Run<PopulateReferenceMapsPhase>();
......@@ -2064,7 +2064,7 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
}
if (verifier != nullptr) {
verifier->VerifyAssignment();
verifier->VerifyAssignment("End of regalloc pipeline.");
verifier->VerifyGapMoves();
}
......
......@@ -18,7 +18,6 @@ size_t OperandCount(const Instruction* instr) {
return instr->InputCount() + instr->OutputCount() + instr->TempCount();
}
void VerifyEmptyGaps(const Instruction* instr) {
for (int i = Instruction::FIRST_GAP_POSITION;
i <= Instruction::LAST_GAP_POSITION; i++) {
......@@ -28,8 +27,7 @@ void VerifyEmptyGaps(const Instruction* instr) {
}
}
void VerifyAllocatedGaps(const Instruction* instr) {
void VerifyAllocatedGaps(const Instruction* instr, const char* caller_info) {
for (int i = Instruction::FIRST_GAP_POSITION;
i <= Instruction::LAST_GAP_POSITION; i++) {
Instruction::GapPosition inner_pos =
......@@ -38,8 +36,10 @@ void VerifyAllocatedGaps(const Instruction* instr) {
if (moves == nullptr) continue;
for (const MoveOperands* move : *moves) {
if (move->IsRedundant()) continue;
CHECK(move->source().IsAllocated() || move->source().IsConstant());
CHECK(move->destination().IsAllocated());
CHECK_WITH_MSG(
move->source().IsAllocated() || move->source().IsConstant(),
caller_info);
CHECK_WITH_MSG(move->destination().IsAllocated(), caller_info);
}
}
}
......@@ -114,13 +114,14 @@ void RegisterAllocatorVerifier::VerifyOutput(
constraint.virtual_register_);
}
void RegisterAllocatorVerifier::VerifyAssignment() {
void RegisterAllocatorVerifier::VerifyAssignment(const char* caller_info) {
caller_info_ = caller_info;
CHECK(sequence()->instructions().size() == constraints()->size());
auto instr_it = sequence()->begin();
for (const auto& instr_constraint : *constraints()) {
const Instruction* instr = instr_constraint.instruction_;
// All gaps should be totally allocated at this point.
VerifyAllocatedGaps(instr);
VerifyAllocatedGaps(instr, caller_info_);
const size_t operand_count = instr_constraint.operand_constaints_size_;
const OperandConstraint* op_constraints =
instr_constraint.operand_constraints_;
......@@ -211,12 +212,12 @@ void RegisterAllocatorVerifier::CheckConstraint(
const InstructionOperand* op, const OperandConstraint* constraint) {
switch (constraint->type_) {
case kConstant:
CHECK(op->IsConstant());
CHECK_WITH_MSG(op->IsConstant(), caller_info_);
CHECK_EQ(ConstantOperand::cast(op)->virtual_register(),
constraint->value_);
return;
case kImmediate: {
CHECK(op->IsImmediate());
CHECK_WITH_MSG(op->IsImmediate(), caller_info_);
const ImmediateOperand* imm = ImmediateOperand::cast(op);
int value = imm->type() == ImmediateOperand::INLINE
? imm->inline_value()
......@@ -225,40 +226,40 @@ void RegisterAllocatorVerifier::CheckConstraint(
return;
}
case kRegister:
CHECK(op->IsRegister());
CHECK_WITH_MSG(op->IsRegister(), caller_info_);
return;
case kFPRegister:
CHECK(op->IsFPRegister());
CHECK_WITH_MSG(op->IsFPRegister(), caller_info_);
return;
case kExplicit:
CHECK(op->IsExplicit());
CHECK_WITH_MSG(op->IsExplicit(), caller_info_);
return;
case kFixedRegister:
case kRegisterAndSlot:
CHECK(op->IsRegister());
CHECK_WITH_MSG(op->IsRegister(), caller_info_);
CHECK_EQ(LocationOperand::cast(op)->register_code(), constraint->value_);
return;
case kFixedFPRegister:
CHECK(op->IsFPRegister());
CHECK_WITH_MSG(op->IsFPRegister(), caller_info_);
CHECK_EQ(LocationOperand::cast(op)->register_code(), constraint->value_);
return;
case kFixedSlot:
CHECK(op->IsStackSlot() || op->IsFPStackSlot());
CHECK_WITH_MSG(op->IsStackSlot() || op->IsFPStackSlot(), caller_info_);
CHECK_EQ(LocationOperand::cast(op)->index(), constraint->value_);
return;
case kSlot:
CHECK(op->IsStackSlot() || op->IsFPStackSlot());
CHECK_WITH_MSG(op->IsStackSlot() || op->IsFPStackSlot(), caller_info_);
CHECK_EQ(ElementSizeLog2Of(LocationOperand::cast(op)->representation()),
constraint->value_);
return;
case kNone:
CHECK(op->IsRegister() || op->IsStackSlot());
CHECK_WITH_MSG(op->IsRegister() || op->IsStackSlot(), caller_info_);
return;
case kNoneFP:
CHECK(op->IsFPRegister() || op->IsFPStackSlot());
CHECK_WITH_MSG(op->IsFPRegister() || op->IsFPStackSlot(), caller_info_);
return;
case kSameAsFirst:
CHECK(false);
CHECK_WITH_MSG(false, caller_info_);
return;
}
}
......
......@@ -167,7 +167,7 @@ class RegisterAllocatorVerifier final : public ZoneObject {
RegisterAllocatorVerifier(Zone* zone, const RegisterConfiguration* config,
const InstructionSequence* sequence);
void VerifyAssignment();
void VerifyAssignment(const char* caller_info);
void VerifyGapMoves();
private:
......@@ -257,6 +257,8 @@ class RegisterAllocatorVerifier final : public ZoneObject {
Constraints constraints_;
ZoneMap<RpoNumber, BlockAssessments*> assessments_;
ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_;
// TODO(chromium:725559): remove after we understand this bug's root cause.
const char* caller_info_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier);
};
......
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