dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.12k stars 1.57k forks source link

[gardening/vm] vm/dart/devirtualization_during_inlining_il_test not inlining on all bots #54940

Open dcharkes opened 7 months ago

dcharkes commented 7 months ago

There are new test failures on Use the test file to check for navigation results....[analysis_server] Fix timeout in LSP-over-Legacy macro integration tests.

The tests

vm/dart/devirtualization_during_inlining_il_test Crash (expected Pass)

are failing on configurations

dartkp-weak-asserts-linux-release-x64
stdout:
matching IL (After AllocateRegisters) for test
Failed to match: Unmatched instruction: interpolate <- StaticCall({i: [boxed_index]}) in block B3
B0[GraphEntry] {
  v0 <- Constant[value: null]() T{Null, Null, +null}
  v79 <- UnboxedConstant[value: 0, representation: int64]() T{_Smi, _Smi}
  v80 <- UnboxedConstant[value: 10, representation: int64]() T{_Smi, _Smi}
  v81 <- UnboxedConstant[value: 1, representation: int64]() T{_Smi, _Smi}
}
B1[FunctionEntry] {
  v2 <- Parameter[index: 0]() T{TestIterable, TestIterable}
}
  CheckStackOverflow()
  Goto() goto [5]
B5[JoinEntry]
  v78 <- Phi(v79, v24) T{int}
  CheckStackOverflow()
  Branch if RelationalOp[kind: >=](v78, v80) then goto [4, 3]
B4[TargetEntry]
  ParallelMove()
  Return(v0)
B3[TargetEntry]
  ParallelMove()
  v24 <- BinaryInt64Op[op_kind: +](v78, v81) T{int}
  ParallelMove()
  v86 <- BoxInt64(v78)
  MoveArgument(v2)
  MoveArgument(v86)
  v25 <- StaticCall[function: TestIterable.elementAt](v2, v86) T{int?, +null}
  MoveArgument(v25)
  v11 <- StaticCall[function: _StringBase._interpolateSingle](v25) T{String, +null}
  MoveArgument(v11)
  StaticCall[function: printToConsole](v11)
  Goto() goto [5]

stderr:
Unhandled exception:
Failed to match
#0      FlowGraph.match (package:vm/testing/il_matchers.dart:49:9)
#1      matchIL$test (file:///b/s/w/ir/runtime/tests/vm/dart/devirtualization_during_inlining_il_test.dart:58:9)
#2      _LibraryMirror._invoke (dart:mirrors-patch/mirrors_impl.dart:1001:68)
#3      _ObjectMirror.invoke (dart:mirrors-patch/mirrors_impl.dart:250:25)
#4      TestCase.run (file:///b/s/w/ir/pkg/vm/bin/compare_il.dart:65:13)
#5      main (file:///b/s/w/ir/pkg/vm/bin/compare_il.dart:39:10)
<asynchronous suspension>

--- Re-run this test:
python3 tools/test.py -n dartkp-weak-asserts-linux-release-x64 vm/dart/devirtualization_during_inlining_il_test

Expected flow graph:

void matchIL$test(FlowGraph graph) {
  graph.match([
    match.block('Graph'),
    match.block('Function', [
      'obj' << match.Parameter(index: 0),
      match.CheckStackOverflow(),
      match.Goto('LoopHeader'),
    ]),
    'LoopHeader' <<
        match.block('Join', [
          'index' << match.Phi(match.any, 'inc'),
          match.CheckStackOverflow(),
          match.Branch(match.RelationalOp('index', match.any, kind: '>='),
              ifTrue: 'LoopExit', ifFalse: 'LoopBody'),
        ]),
    'LoopExit' <<
        match.block('Target', [
          match.Return(),
        ]),
    'LoopBody' <<
        match.block('Target', [
          'inc' << match.BinaryInt64Op('index', match.any),
          'boxed_index' << match.BoxInt64('index'),
          'interpolate' << match.StaticCall('boxed_index'),
          match.StaticCall('interpolate'),
          match.Goto('LoopHeader'),
        ]),
  ]);
}

It looks like the inliner is not inlining the supposed to be inlined methods:

class TestIterable extends IterableBase<int> {
  @pragma('vm:prefer-inline')
  TestIterator get iterator => TestIterator(this);

  @override
  int get length => 10;

  @pragma('vm:prefer-inline')
  int elementAt(int index) {
    return index;
  }
}

Logs: https://dart-ci.appspot.com/log/vm-kernel-precomp-linux-release-x64/dartkp-weak-asserts-linux-release-x64/15940/vm/dart/devirtualization_during_inlining_il_test

Will bisect locally.

dart tools/bisect.dart \
-Dend=1e11807735052984c9838a7af72a95c8fb2f78aa \
-Dstart=5394052641e4b9c07713b5c1eea66dd2897c8bac \
-Dtest_command="python3 tools/test.py --build -n dartkp-weak-asserts-linux-release-x64 vm/dart/devirtualization_during_inlining_il_test" \
-Dfailure_string="Failed to match: Unmatched instruction:"

Commit range 2bdcfb7035d...5394052641e4b9c07713b5c1eea66dd2897c8bac. Ensuring SDK repo in /usr/local/google/home/dacoharkes/dart-sdk/sdk/. Ensuring failure reproduces on 5394052641e4b9c07713b5c1eea66dd2897c8bac. Commit 5394052641e4b9c07713b5c1eea66dd2897c8bac, reproduces failure. Ensuring failure does not reproduce on 2bdcfb7035d. Commit 2bdcfb7035d, does not reproduce failure. Bisecting 2bdcfb7035d...5394052641e (26 commits). Trying 6cfb95ce7cc. Commit 6cfb95ce7cc, reproduces failure. Bisecting 2bdcfb7035d...6cfb95ce7cc (13 commits). Trying 44fedd4dbd5. Commit 44fedd4dbd5, reproduces failure. Bisecting 2bdcfb7035d...44fedd4dbd5 (7 commits). Trying 9415aba0593. Commit 9415aba0593, does not reproduce failure. Bisecting 9415aba0593...44fedd4dbd5 (3 commits). Trying 9a4d8b47cfd. Commit 9a4d8b47cfd, reproduces failure. Bisecting 9415aba0593...9a4d8b47cfd (2 commits). Trying 628d744391f. Commit 628d744391f, reproduces failure. Bisected to 628d744391f.

Ran twice, ended with the same result.

This seems an unlikely commit to cause this.

Test history on all the bots: https://dart-ci.web.app/#showLatestFailures=false&test=vm/dart/devirtualization_during_inlining_il_test

Also failing on another bot already: https://dart-current-results.web.app/#/filter=vm/dart/devirtualization_during_inlining_il_test&showAll

Log on other bot: https://dart-ci.appspot.com/log/any/vm-aot-optimization-level-linux-release-x64/134/vm/dart/devirtualization_during_inlining_il_test

Seems to be the same issue, not inlining.

Previous failure approved on:

dcharkes commented 7 months ago

FYI @mraleph It looks like the inliner doesn't inline properly on: