EVALUATION
In current codebase (apparently after some refactoring of ciTypeFlow.*),
cloning of loop head was implemented in ciTypeFlow::clone_loop_head() method,
which does the following transformation:
> _______ ______ _______ ______ _______
> | |----->| | | | | |------>| head's|
> --->| head | | body | is transformed to: --->| head |---->| body | | clone |---->
> |_______|<-----|______| |_______| |______|<------|_______|
> (backedge_copy)
But current implementation of ciTypeFlow::clone_loop_head() can't correctly
transform graphs like this:
> _______ ______
> | |----->| |
> --->| head |<-----| body |
> |_______|<-----|______|
Because only _one_ of body's successors is moved to the cloned block:
> // tail->head becomes tail->clone
> for (SuccIter iter(tail); !iter.done(); iter.next()) {
> if (iter.succ() == head) {
> iter.set_succ(clone);
> break;
> }
> }
Which results in the following graph, where the "body" block breaks the
assertion, having two different successors starting at the same bci (see also
attached typeflow_run_error.log):
> _______ ______ _______
> | |----->| |------>| head |
> --->| head | | body | | clone |----->
> |_______|<-----|______|<------|_______|
> (backedge_copy)
|