Stream: git-wasmtime

Topic: wasmtime / Issue #2405 MachInst backend: use fallthrough ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 12 2020 at 20:10):

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 a jump, 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 a jump: 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 in BlockLoweringOrder to prefer fallthrough blocks whenever possible. This will result in better block ordering when the frontend is explicit about it.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 12 2020 at 20:11):

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 a jump, 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 a jump: 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 in BlockLoweringOrder to prefer fallthrough blocks whenever possible. This will result in better block ordering when the frontend is explicit about it.


Last updated: Nov 22 2024 at 17:03 UTC