Commit 3dc2635d authored by mtrofin's avatar mtrofin Committed by Commit bot

[turbofan] Validate split-edge form

We assume split-edge form throughout the register allocation pipeline,
so added validation in isel.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#33789}
parent f2222403
...@@ -615,6 +615,20 @@ InstructionBlocks* InstructionSequence::InstructionBlocksFor( ...@@ -615,6 +615,20 @@ InstructionBlocks* InstructionSequence::InstructionBlocksFor(
return blocks; return blocks;
} }
void InstructionSequence::Validate() {
// Validate blocks are in edge-split form: no block with multiple successors
// has an edge to a block (== a successor) with more than one predecessors.
for (const InstructionBlock* block : instruction_blocks()) {
if (block->SuccessorCount() > 1) {
for (const RpoNumber& successor_id : block->successors()) {
const InstructionBlock* successor = InstructionBlockAt(successor_id);
// Expect precisely one predecessor: "block".
CHECK(successor->PredecessorCount() == 1 &&
successor->predecessors()[0] == block->rpo_number());
}
}
}
}
void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) { void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) {
int ao = 0; int ao = 0;
...@@ -648,6 +662,10 @@ InstructionSequence::InstructionSequence(Isolate* isolate, ...@@ -648,6 +662,10 @@ InstructionSequence::InstructionSequence(Isolate* isolate,
representations_(zone()), representations_(zone()),
deoptimization_entries_(zone()) { deoptimization_entries_(zone()) {
block_starts_.reserve(instruction_blocks_->size()); block_starts_.reserve(instruction_blocks_->size());
#if DEBUG
Validate();
#endif
} }
......
...@@ -1332,6 +1332,8 @@ class InstructionSequence final : public ZoneObject { ...@@ -1332,6 +1332,8 @@ class InstructionSequence final : public ZoneObject {
void PrintBlock(const RegisterConfiguration* config, int block_id) const; void PrintBlock(const RegisterConfiguration* config, int block_id) const;
void PrintBlock(int block_id) const; void PrintBlock(int block_id) const;
void Validate();
private: private:
friend std::ostream& operator<<(std::ostream& os, friend std::ostream& operator<<(std::ostream& os,
const PrintableInstructionSequence& code); const PrintableInstructionSequence& code);
......
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