[LoopReroll] Don't crash on dead code

If a PHI has no users, don't crash; bail gracefully. This shouldn't
happen often, but we can make no guarantees that previous passes didn't leave
dead code around.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229405 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
James Molloy
2015-02-16 17:01:52 +00:00
parent c21da273fe
commit 4b739069e4
2 changed files with 38 additions and 0 deletions

View File

@@ -511,6 +511,8 @@ void LoopReroll::SimpleLoopReduction::add(Loop *L) {
// (including the PHI), except for the last value (which is used by the PHI
// and also outside the loop).
Instruction *C = Instructions.front();
if (C->user_empty())
return;
do {
C = cast<Instruction>(*C->user_begin());