LICM: Don't crash when an instruction is used by an unreachable BB
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 2 Sep 2014 16:22:00 +0000 (16:22 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 2 Sep 2014 16:22:00 +0000 (16:22 +0000)
commit9e1f653e2faeae682c3107e146b73d05bf61081d
tree63774aa06322acf236e6178044512f0a206546d3
parent46484879254f6eac714b020f455e3756a41cd291
LICM: Don't crash when an instruction is used by an unreachable BB

Summary:
BBs might contain non-LCSSA'd values after the LCSSA pass is run if they
are unreachable from the entry block.

Normally, the users of the instruction would be PHIs but the unreachable
BBs have normal users; rewrite their uses to be undef values.

An alternative fix could involve fixing this at LCSSA but that would
require this invariant to hold after subsequent transforms.  If a BB
created an unreachable block, they would be in violation of this.

This fixes PR19798.

Differential Revision: http://reviews.llvm.org/D5146

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216911 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LICM.cpp
test/Transforms/LICM/PR19798.ll [new file with mode: 0644]