Skip to content

Commit

Permalink
[vm/compiler] Refine type information when replacing definitions.
Browse files Browse the repository at this point in the history
This way, the new type information can be used immediately by
this and following passes instead of only passes after the next
type propagation phase.

Change-Id: Id27c3789c7c32f5775da5ef933bc56cb58c2a203
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101826
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
  • Loading branch information
sstrickl authored and commit-bot@chromium.org committed Jun 6, 2019
1 parent b9e877b commit 2e7501b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions runtime/vm/compiler/backend/il.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ void Definition::ReplaceUsesWith(Definition* other) {
while (next != NULL) {
current = next;
current->set_definition(other);
current->RefineReachingType(other->Type());
next = current->next_use();
}

Expand All @@ -1330,6 +1331,7 @@ void Definition::ReplaceUsesWith(Definition* other) {
while (next != NULL) {
current = next;
current->set_definition(other);
current->RefineReachingType(other->Type());
next = current->next_use();
}
next = other->env_use_list();
Expand Down
29 changes: 28 additions & 1 deletion runtime/vm/compiler/backend/redundancy_elimination_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,33 @@ ISOLATE_UNIT_TEST_CASE(LoadOptimizer_AliasingViaLoadElimination_AcrossBlocks) {
Invoke(root_library, "main");

TestPipeline pipeline(function, CompilerPass::kJIT);
FlowGraph* flow_graph = pipeline.RunPasses({});
// Recent changes actually compile the function into a single basic
// block, so we need to test right after the load optimizer has been run.
// Have checked that this test still fails appropriately using the load
// optimizer prior to the fix (commit 2a237327).
FlowGraph* flow_graph = pipeline.RunPasses({
CompilerPass::kComputeSSA,
CompilerPass::kApplyICData,
CompilerPass::kTryOptimizePatterns,
CompilerPass::kSetOuterInliningId,
CompilerPass::kTypePropagation,
CompilerPass::kApplyClassIds,
CompilerPass::kInlining,
CompilerPass::kTypePropagation,
CompilerPass::kApplyClassIds,
CompilerPass::kTypePropagation,
CompilerPass::kApplyICData,
CompilerPass::kCanonicalize,
CompilerPass::kBranchSimplify,
CompilerPass::kIfConvert,
CompilerPass::kCanonicalize,
CompilerPass::kConstantPropagation,
CompilerPass::kOptimisticallySpecializeSmiPhis,
CompilerPass::kTypePropagation,
CompilerPass::kWidenSmiToInt32,
CompilerPass::kSelectRepresentations,
CompilerPass::kCSE,
});

auto entry = flow_graph->graph_entry()->normal_entry();
EXPECT(entry != nullptr);
Expand All @@ -698,6 +724,7 @@ ISOLATE_UNIT_TEST_CASE(LoadOptimizer_AliasingViaLoadElimination_AcrossBlocks) {
kMatchAndMoveBranchTrue,
kMatchAndMoveBranchTrue,
kMatchAndMoveBranchFalse,
kMatchAndMoveBranchFalse,
{kMatchAndMoveUnboxedConstant, &double_one},
{kMatchAndMoveStoreIndexed, &first_store},
kMatchAndMoveBranchFalse,
Expand Down

0 comments on commit 2e7501b

Please sign in to comment.