Page MenuHomePhabricator

[MBB] add a missing corner case in UpdateTerminator()

Authored by haicheng on Jun 28 2016, 12:14 PM.



If the layout after the block placement is like this

        JGE_1 <BB#9>, %EFLAGS<imp-use>
    Successors according to CFG: BB#9(0x80000000 / 0x80000000 = 100.00%)


where BB#8 ends with a conditional branch, but the next block is not its successor. The conditional branch should be changed to unconditional branch in MachineBasicBlock::UpdateTerminator(), but this case is missing.

In cases like above example, the results returned by AnalyzeBranch() are: TBB = branch target; FBB = nullptr; Cond = branch condition (not empty)

This corner cases happens if a block (e.g. BB#8) branches and fallthourghs into the same block (e.g. BB#9) before the block placement, and the block placement moves this successor (e.g. BB#9) somewhere else.

Diff Detail


Event Timeline

haicheng updated this revision to Diff 62121.Jun 28 2016, 12:14 PM
haicheng retitled this revision from to [MBB] add a missing corner case in UpdateTerminator().
haicheng updated this object.
haicheng set the repository for this revision to rL LLVM.
haicheng added a subscriber: llvm-commits.
haicheng updated this revision to Diff 62126.Jun 28 2016, 12:19 PM

update the comment.

uabelho edited edge metadata.Jun 30 2016, 1:49 AM

This looks good to me.
It solves the problem we've seen and I haven't noticed anything bad during testing.

majnemer accepted this revision.Jul 2 2016, 10:29 PM
majnemer edited edge metadata.


This revision is now accepted and ready to land.Jul 2 2016, 10:29 PM
This revision was automatically updated to reflect the committed changes.