JIT: fgReorderBlocks does nonsensical things #53636
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
I added some diagnostic output to
fgReorderBlocks
to try and better understand the logic.One odd thing I noticed is that it will often rearrange zero-weight blocks, eg:
The proximate cause for this is that it is adding/subtracting absolute values to block weights, which is nonsensical; for instance the decision above comes from this bit of code, which takes a zero weight block and deduces a
hotWeight
of 0.5:runtime/src/coreclr/jit/fgopt.cpp
Lines 4499 to 4505 in f2f4f50
There are several other examples of this sort of logic in this method.
After all is done we can still see cases where the hot blocks in the method are not compact, eg in the example above we end up with:
I would suggest this entire method be rewritten not to try and solve block ordering as an incremental problem, but instead consider starting with a decent global layout (likely based on a profile-greedy reverse post order) and then trying to incrementally improve.
category:cq
theme:block-layout
The text was updated successfully, but these errors were encountered: