<p>
        Hi, there!
</p>
<p>
        <br>
</p>
<p>
        There are situations where a machine basic block has to be split into two machine basic blocks, e.g., to place a constant pool entry or to fix a conditional branch so that its target is within its range (https://reviews.llvm.org/D38918).
</p>
<p>
        <br>
</p>
<p>
        However, it doesn't appear to be straightforward how the control flow graph should be updated when a machine basic block is split, especially when the split point is between two branches. In this case, in order to determine the successors of each of the two machine basic block, one needs to know the target of each terminator. If we ignore indirect branches whose targets are not known at compile-time, I wonder whether something like the following is viable or not:
</p>
<p>
        <br>
</p>
<p>
        empty mbb.successors
</p>
<p>
        fallthrough = true
</p>
<p>
        for each terminator i in machine basic block mbb
</p>
<p>
        do
</p>
<p>
            if i is control flow barrier and i is not predicable            // Is this the correct way to determine whether an instruction may fall through?
</p>
<p>
                fallthrough = false
</p>
<p>
                break                                          // Instructions after the first non-predicable barrier cannot be executed, right?
</p>
<p>
            fi
        </p><p>
                    ignore operands of i if i is a return
        </p>

<p>
            for each operand o of i
</p>
<p>
            do
</p>
<p>
                if o is a machine basic block                // Can an instruction other than a jump table instruction target multiple machine basic blocks?
</p>
<p>
                    add o to mbb.successors
</p>
<p>
                fi
</p>
<p>
                if o is a jump table index
</p>
<p>
                    add all machine basic blocks in the jump table to mbb.successors
</p>
<p>
                fi
</p>
<p>
            done
</p>
<p>
        done
        </p><p>
                if fallthrough == true
        </p>
        <p>
                    add the layout successor to mbb.successors, if one exists
        </p>
fi

<p>
        <br>
</p>
<p>
        Am I missing something?
</p>
<p>
        Please give me some advice.
</p>
<p>
        Thank you!
</p>
<p>
        <br>
</p>
<p>
        Ming Zhang
</p>