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,8 +762,8 @@ void PrintCode(Isolate* isolate, Handle<Code> code,
#endif // ENABLE_DISASSEMBLER
}
void TraceSchedule(OptimizedCompilationInfo* info, PipelineData* data,
Schedule* schedule, const char* phase_name) {
void TraceScheduleAndVerify(OptimizedCompilationInfo* info, PipelineData* data,
Schedule* schedule, const char* phase_name) {
if (info->trace_turbo_json_enabled()) {
AllowHandleDereference allow_deref;
TurboJsonFile json_of(info, std::ios_base::app);
......@@ -783,8 +783,9 @@ void TraceSchedule(OptimizedCompilationInfo* info, PipelineData* data,
OFStream os(tracing_scope.file());
os << "-- Schedule --------------------------------------\n" << *schedule;
}
}
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
}
class SourcePositionWrapper final : public Reducer {
public:
......@@ -1630,9 +1631,8 @@ struct EffectControlLinearizationPhase {
Schedule* schedule = Scheduler::ComputeSchedule(
temp_zone, data->graph(), Scheduler::kTempSchedule,
&data->info()->tick_counter());
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
TraceSchedule(data->info(), data, schedule,
"effect linearization schedule");
TraceScheduleAndVerify(data->info(), data, schedule,
"effect linearization schedule");
MaskArrayIndexEnable mask_array_index =
(data->info()->GetPoisoningMitigationLevel() !=
......@@ -1830,8 +1830,9 @@ struct ScheduledEffectControlLinearizationPhase {
// TODO(rmcilroy) Avoid having to rebuild rpo_order on schedule each time.
Scheduler::ComputeSpecialRPO(temp_zone, data->schedule());
TraceSchedule(data->info(), data, data->schedule(),
"effect linearization schedule");
if (FLAG_turbo_verify) Scheduler::GenerateDominatorTree(data->schedule());
TraceScheduleAndVerify(data->info(), data, data->schedule(),
"effect linearization schedule");
}
};
......@@ -1848,8 +1849,9 @@ struct ScheduledMachineLoweringPhase {
// TODO(rmcilroy) Avoid having to rebuild rpo_order on schedule each time.
Scheduler::ComputeSpecialRPO(temp_zone, data->schedule());
TraceSchedule(data->info(), data, data->schedule(),
"machine lowered schedule");
if (FLAG_turbo_verify) Scheduler::GenerateDominatorTree(data->schedule());
TraceScheduleAndVerify(data->info(), data, data->schedule(),
"machine lowered schedule");
}
};
......@@ -1943,7 +1945,6 @@ struct ComputeSchedulePhase {
data->info()->is_splitting_enabled() ? Scheduler::kSplitNodes
: Scheduler::kNoFlags,
&data->info()->tick_counter());
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
data->set_schedule(schedule);
}
};
......@@ -2968,7 +2969,7 @@ void PipelineImpl::ComputeScheduledGraph() {
RunPrintAndVerify(LateGraphTrimmingPhase::phase_name(), true);
Run<ComputeSchedulePhase>();
TraceSchedule(data->info(), data, data->schedule(), "schedule");
TraceScheduleAndVerify(data->info(), data, data->schedule(), "schedule");
}
bool PipelineImpl::SelectInstructions(Linkage* linkage) {
......
......@@ -58,7 +58,7 @@ Schedule* Scheduler::ComputeSchedule(Zone* zone, Graph* graph, Flags flags,
scheduler.BuildCFG();
scheduler.ComputeSpecialRPONumbering();
scheduler.GenerateImmediateDominatorTree();
scheduler.GenerateDominatorTree();
scheduler.PrepareUses();
scheduler.ScheduleEarly();
......@@ -1165,17 +1165,18 @@ void Scheduler::PropagateImmediateDominators(BasicBlock* block) {
}
}
void Scheduler::GenerateImmediateDominatorTree() {
TRACE("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
void Scheduler::GenerateDominatorTree(Schedule* schedule) {
// 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.
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.
......
......@@ -42,6 +42,9 @@ class V8_EXPORT_PRIVATE Scheduler {
// Compute the RPO of blocks in an existing 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:
// Placement of a node changes during scheduling. The placement state
// transitions over time while the scheduler is choosing a position:
......@@ -98,7 +101,7 @@ class V8_EXPORT_PRIVATE Scheduler {
void IncrementUnscheduledUseCount(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.
friend class CFGBuilder;
......@@ -107,7 +110,7 @@ class V8_EXPORT_PRIVATE Scheduler {
// Phase 2: Compute special RPO and dominator tree.
friend class SpecialRPONumberer;
void ComputeSpecialRPONumbering();
void GenerateImmediateDominatorTree();
void GenerateDominatorTree();
// Phase 3: Prepare use counts for nodes.
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