dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.98k stars 4.66k forks source link

JIT: tracking down and fixing stray dependences on bbNum #84052

Open AndyAyersMS opened 1 year ago

AndyAyersMS commented 1 year ago

(summary of an idea Bruce and I were discussing)

If you add new calls to fgRenumberBlocks you can observe diffs, sometimes radically large ones. This likely means that there is code in the jit that is depending on bbNum without ensuring that bbNum has a stable or intended meaning.

We should adopt the discipline that jit behavior that depends on bbNum be required to establish valid bbNums first. One way to do this is:

ghost commented 1 year ago

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak See info in area-owners.md if you want to be subscribed.

Issue Details
(summary of an idea Bruce and I were discussing) If you add new calls to `fgRenumberBlocks` you can observe diffs, sometimes radically large ones. This likely means that there is code in the jit that is depending on `bbNum` without ensuring that `bbNum` has a stable or intended meaning. We should adopt the discipline that jit behavior that depends on `bbNum` be required to establish valid `bbNums` first. One way to do this is: * add `fgRenumberBlocks` to the pre or post phase list, enabling for phases back to front * run some test suite (SPMI say) seeing if this new renumbering leads to diffs * if so, then * if the diffs are because a phase or component is relying on bbNum for heuristics, add a suitable renumbering (in the phase itself, not in the pre phase list) to set the expected `bbNums` * if the diffs are gratuitous, fix the code to check something more meaningful / durable instead * move on to the next phase
Author: AndyAyersMS
Assignees: -
Labels: `area-CodeGen-coreclr`, `untriaged`
Milestone: -