[LoopUnroll] Add check to Latch's terminator in UnrollRuntimeLoopRemainder
authorDavid Green <david.green@arm.com>
Tue, 25 Sep 2018 10:08:47 +0000 (10:08 +0000)
committerDavid Green <david.green@arm.com>
Tue, 25 Sep 2018 10:08:47 +0000 (10:08 +0000)
commit9108c2b92155decd107489f2069907b44f234250
tree7d031061b1680b4927cacc21b07c859887c62c37
parent029aa8ec7f52a6dabd3ac3b15e488ebe0148ae2c
[LoopUnroll] Add check to Latch's terminator in UnrollRuntimeLoopRemainder

In this patch, I'm adding an extra check to the Latch's terminator in llvm::UnrollRuntimeLoopRemainder,
similar to how it is already done in the llvm::UnrollLoop.

The compiler would crash if this function is called with a malformed loop.

Patch by Rodrigo Caetano Rocha!

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

llvm-svn: 342958
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
llvm/test/Transforms/LoopUnroll/runtime-loop-non-exiting-latch.ll [new file with mode: 0644]
llvm/unittests/Transforms/Utils/CMakeLists.txt
llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp [new file with mode: 0644]