[CodeGenPrepare] Fix crash due to an invalid CFG
authorBrendon Cahoon <bcahoon@codeaurora.org>
Mon, 17 Apr 2017 19:11:04 +0000 (19:11 +0000)
committerBrendon Cahoon <bcahoon@codeaurora.org>
Mon, 17 Apr 2017 19:11:04 +0000 (19:11 +0000)
commit7769a0854efe4726422137d6d6aa33288e1c9a51
treefd6027404b82a79e7707c498526a0e0e8b823fd8
parent54c781a0b5d428d712af8bb610b8162bb9ef0a84
[CodeGenPrepare] Fix crash due to an invalid CFG

The splitIndirectCriticalEdges function generates and invalid CFG when the
'Target' basic block is a loop to itself. When this occurs, the code that
updates the predecessor terminator needs to update the terminator in the split
basic block.

This occurs when there is an edge from block D back to D. Since D is split in
to D0 and D1, the code needs to update the terminator in D1. But D1 is not in
the OtherPreds vector, so it was not getting updated.

Differential Revision: https://reviews.llvm.org/D32126

llvm-svn: 300480
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/test/Transforms/CodeGenPrepare/split-indirect-loop.ll [new file with mode: 0644]