Commit 65fcf0df authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[TurboProp] Verify schedule after each scheduled lowering pass.

Add support to verify the update schedule after ScheduledEffectControlLinearization
and ScheduledMachineLowering phases. To do so, we need to recompute the immediate
dominator tree of the scheduled blocks.

BUG=v8:9684

Change-Id: I849fb7e3e699ca56c5115d90a53006d517cf3fe5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1881160
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64596}
parent be0e2c26
...@@ -762,7 +762,7 @@ void PrintCode(Isolate* isolate, Handle<Code> code, ...@@ -762,7 +762,7 @@ void PrintCode(Isolate* isolate, Handle<Code> code,
#endif // ENABLE_DISASSEMBLER #endif // ENABLE_DISASSEMBLER
} }
void TraceSchedule(OptimizedCompilationInfo* info, PipelineData* data, void TraceScheduleAndVerify(OptimizedCompilationInfo* info, PipelineData* data,
Schedule* schedule, const char* phase_name) { Schedule* schedule, const char* phase_name) {
if (info->trace_turbo_json_enabled()) { if (info->trace_turbo_json_enabled()) {
AllowHandleDereference allow_deref; AllowHandleDereference allow_deref;
...@@ -783,8 +783,9 @@ void TraceSchedule(OptimizedCompilationInfo* info, PipelineData* data, ...@@ -783,8 +783,9 @@ void TraceSchedule(OptimizedCompilationInfo* info, PipelineData* data,
OFStream os(tracing_scope.file()); OFStream os(tracing_scope.file());
os << "-- Schedule --------------------------------------\n" << *schedule; os << "-- Schedule --------------------------------------\n" << *schedule;
} }
}
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
}
class SourcePositionWrapper final : public Reducer { class SourcePositionWrapper final : public Reducer {
public: public:
...@@ -1630,8 +1631,7 @@ struct EffectControlLinearizationPhase { ...@@ -1630,8 +1631,7 @@ struct EffectControlLinearizationPhase {
Schedule* schedule = Scheduler::ComputeSchedule( Schedule* schedule = Scheduler::ComputeSchedule(
temp_zone, data->graph(), Scheduler::kTempSchedule, temp_zone, data->graph(), Scheduler::kTempSchedule,
&data->info()->tick_counter()); &data->info()->tick_counter());
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule); TraceScheduleAndVerify(data->info(), data, schedule,
TraceSchedule(data->info(), data, schedule,
"effect linearization schedule"); "effect linearization schedule");
MaskArrayIndexEnable mask_array_index = MaskArrayIndexEnable mask_array_index =
...@@ -1830,7 +1830,8 @@ struct ScheduledEffectControlLinearizationPhase { ...@@ -1830,7 +1830,8 @@ struct ScheduledEffectControlLinearizationPhase {
// TODO(rmcilroy) Avoid having to rebuild rpo_order on schedule each time. // TODO(rmcilroy) Avoid having to rebuild rpo_order on schedule each time.
Scheduler::ComputeSpecialRPO(temp_zone, data->schedule()); Scheduler::ComputeSpecialRPO(temp_zone, data->schedule());
TraceSchedule(data->info(), data, data->schedule(), if (FLAG_turbo_verify) Scheduler::GenerateDominatorTree(data->schedule());
TraceScheduleAndVerify(data->info(), data, data->schedule(),
"effect linearization schedule"); "effect linearization schedule");
} }
}; };
...@@ -1848,7 +1849,8 @@ struct ScheduledMachineLoweringPhase { ...@@ -1848,7 +1849,8 @@ struct ScheduledMachineLoweringPhase {
// TODO(rmcilroy) Avoid having to rebuild rpo_order on schedule each time. // TODO(rmcilroy) Avoid having to rebuild rpo_order on schedule each time.
Scheduler::ComputeSpecialRPO(temp_zone, data->schedule()); Scheduler::ComputeSpecialRPO(temp_zone, data->schedule());
TraceSchedule(data->info(), data, data->schedule(), if (FLAG_turbo_verify) Scheduler::GenerateDominatorTree(data->schedule());
TraceScheduleAndVerify(data->info(), data, data->schedule(),
"machine lowered schedule"); "machine lowered schedule");
} }
}; };
...@@ -1943,7 +1945,6 @@ struct ComputeSchedulePhase { ...@@ -1943,7 +1945,6 @@ struct ComputeSchedulePhase {
data->info()->is_splitting_enabled() ? Scheduler::kSplitNodes data->info()->is_splitting_enabled() ? Scheduler::kSplitNodes
: Scheduler::kNoFlags, : Scheduler::kNoFlags,
&data->info()->tick_counter()); &data->info()->tick_counter());
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
data->set_schedule(schedule); data->set_schedule(schedule);
} }
}; };
...@@ -2968,7 +2969,7 @@ void PipelineImpl::ComputeScheduledGraph() { ...@@ -2968,7 +2969,7 @@ void PipelineImpl::ComputeScheduledGraph() {
RunPrintAndVerify(LateGraphTrimmingPhase::phase_name(), true); RunPrintAndVerify(LateGraphTrimmingPhase::phase_name(), true);
Run<ComputeSchedulePhase>(); Run<ComputeSchedulePhase>();
TraceSchedule(data->info(), data, data->schedule(), "schedule"); TraceScheduleAndVerify(data->info(), data, data->schedule(), "schedule");
} }
bool PipelineImpl::SelectInstructions(Linkage* linkage) { bool PipelineImpl::SelectInstructions(Linkage* linkage) {
......
...@@ -58,7 +58,7 @@ Schedule* Scheduler::ComputeSchedule(Zone* zone, Graph* graph, Flags flags, ...@@ -58,7 +58,7 @@ Schedule* Scheduler::ComputeSchedule(Zone* zone, Graph* graph, Flags flags,
scheduler.BuildCFG(); scheduler.BuildCFG();
scheduler.ComputeSpecialRPONumbering(); scheduler.ComputeSpecialRPONumbering();
scheduler.GenerateImmediateDominatorTree(); scheduler.GenerateDominatorTree();
scheduler.PrepareUses(); scheduler.PrepareUses();
scheduler.ScheduleEarly(); scheduler.ScheduleEarly();
...@@ -1165,17 +1165,18 @@ void Scheduler::PropagateImmediateDominators(BasicBlock* block) { ...@@ -1165,17 +1165,18 @@ void Scheduler::PropagateImmediateDominators(BasicBlock* block) {
} }
} }
void Scheduler::GenerateDominatorTree(Schedule* schedule) {
void Scheduler::GenerateImmediateDominatorTree() {
TRACE("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
// Seed start block to be the first dominator. // Seed start block to be the first dominator.
schedule_->start()->set_dominator_depth(0); schedule->start()->set_dominator_depth(0);
// Build the block dominator tree resulting from the above seed. // Build the block dominator tree resulting from the above seed.
PropagateImmediateDominators(schedule_->start()->rpo_next()); PropagateImmediateDominators(schedule->start()->rpo_next());
} }
void Scheduler::GenerateDominatorTree() {
TRACE("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
GenerateDominatorTree(schedule_);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Phase 3: Prepare use counts for nodes. // Phase 3: Prepare use counts for nodes.
......
...@@ -42,6 +42,9 @@ class V8_EXPORT_PRIVATE Scheduler { ...@@ -42,6 +42,9 @@ class V8_EXPORT_PRIVATE Scheduler {
// Compute the RPO of blocks in an existing schedule. // Compute the RPO of blocks in an existing schedule.
static BasicBlockVector* ComputeSpecialRPO(Zone* zone, Schedule* schedule); static BasicBlockVector* ComputeSpecialRPO(Zone* zone, Schedule* schedule);
// Computes the dominator tree on an existing schedule that has RPO computed.
static void GenerateDominatorTree(Schedule* schedule);
private: private:
// Placement of a node changes during scheduling. The placement state // Placement of a node changes during scheduling. The placement state
// transitions over time while the scheduler is choosing a position: // transitions over time while the scheduler is choosing a position:
...@@ -98,7 +101,7 @@ class V8_EXPORT_PRIVATE Scheduler { ...@@ -98,7 +101,7 @@ class V8_EXPORT_PRIVATE Scheduler {
void IncrementUnscheduledUseCount(Node* node, int index, Node* from); void IncrementUnscheduledUseCount(Node* node, int index, Node* from);
void DecrementUnscheduledUseCount(Node* node, int index, Node* from); void DecrementUnscheduledUseCount(Node* node, int index, Node* from);
void PropagateImmediateDominators(BasicBlock* block); static void PropagateImmediateDominators(BasicBlock* block);
// Phase 1: Build control-flow graph. // Phase 1: Build control-flow graph.
friend class CFGBuilder; friend class CFGBuilder;
...@@ -107,7 +110,7 @@ class V8_EXPORT_PRIVATE Scheduler { ...@@ -107,7 +110,7 @@ class V8_EXPORT_PRIVATE Scheduler {
// Phase 2: Compute special RPO and dominator tree. // Phase 2: Compute special RPO and dominator tree.
friend class SpecialRPONumberer; friend class SpecialRPONumberer;
void ComputeSpecialRPONumbering(); void ComputeSpecialRPONumbering();
void GenerateImmediateDominatorTree(); void GenerateDominatorTree();
// Phase 3: Prepare use counts for nodes. // Phase 3: Prepare use counts for nodes.
friend class PrepareUsesVisitor; friend class PrepareUsesVisitor;
......
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