cfallin opened Issue #2405:
In the new backend's
BlockLoweringOrder
algorithm, we do a DFS to determine the order in which basic blocks should be codegen'd into machine code. The algorithm does a pretty good job of placing edge-blocks appropriately, but does not use hints from the CLIF where it could.In particular, the
fallthrough
instruction currently is defined to act like ajump
, except that its target must come next in the function block order. It was mostly used in old backends' optimization passes to replace jumps to subsequent blocks, but can also be used by code generators (e.g., Lucet in #2395).Following #2395, we correctly generate code for
fallthrough
by just treating it like ajump
: thus we accept a superset of codegen behavior that the old backend does, and generate correct code even when blocks are reordered; but we lose the block-ordering hint.Instead, we should take into account when blocks end in
fallthrough
and alter the DFS logic inBlockLoweringOrder
to prefer fallthrough blocks whenever possible. This will result in better block ordering when the frontend is explicit about it.
cfallin labeled Issue #2405:
In the new backend's
BlockLoweringOrder
algorithm, we do a DFS to determine the order in which basic blocks should be codegen'd into machine code. The algorithm does a pretty good job of placing edge-blocks appropriately, but does not use hints from the CLIF where it could.In particular, the
fallthrough
instruction currently is defined to act like ajump
, except that its target must come next in the function block order. It was mostly used in old backends' optimization passes to replace jumps to subsequent blocks, but can also be used by code generators (e.g., Lucet in #2395).Following #2395, we correctly generate code for
fallthrough
by just treating it like ajump
: thus we accept a superset of codegen behavior that the old backend does, and generate correct code even when blocks are reordered; but we lose the block-ordering hint.Instead, we should take into account when blocks end in
fallthrough
and alter the DFS logic inBlockLoweringOrder
to prefer fallthrough blocks whenever possible. This will result in better block ordering when the frontend is explicit about it.
Last updated: Dec 23 2024 at 13:07 UTC