Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

EBBs aren't working out all that well #796

@lars-t-hansen

Description

@lars-t-hansen

Cranelift uses extended basic blocks (EBBs) for its flow graphs: these are essentially single-entry multiple-exit linear sequences of instructions, they can be composed of what would normally be multiple basic blocks (BBs), namely, they are traces of BBs through subtrees of the BB flow graph. BBs are "classical" but EBBs have some theoretical advantages in that there are fewer of them (so less overhead of time and space) and larger (so some non-global optimizations have greater scope to work in) and faster (computing the immediate dominator of the non-first BB of an EBB is trivial).

However, EBBs have some disadvantages. As BBs are the classical representation of flow graphs, most of the literature uses BBs, and to use classical algorithms directly on EBBs we must perform a translation of the algorithm, or we must reconstruct the BB graph from the EBBs when that translation is not possible. Furthermore, EBBs have a dicey relationship with loops: an EBB can be partly in a loop and partly outside a loop (if a side exit from the EBB is the back edge), so a loop algorithm must either split the EBB at the exit (doable but not currently done, AIUI) or risk being unsound (probably the current situation).

It turns out that several passes of Cranelift reconstruct the BB graph. Supposedly (I have this from @sunfishcode) the SSA construction algorithm does this, and my experimental live range splitter must do it, because it needs to reconstruct the SSA after splitting.

The evidence is thus mounting that EBBs are not the best choice for the flow graphs and that we should consider moving to BBs. This would probably be a large undertaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions