OSDN Git Service

[LoopDeletion] Update exits correctly when multiple duplicate edges from an exiting...
authorAnna Thomas <anna@azul.com>
Thu, 22 Jun 2017 20:20:56 +0000 (20:20 +0000)
committerAnna Thomas <anna@azul.com>
Thu, 22 Jun 2017 20:20:56 +0000 (20:20 +0000)
commit980c01094a3b5a6b6ed412857f87cb097396039a
tree003e6331bc8ca3b166e70245b5543599e3deef7b
parentd40aee4db00032049c7134621cf75b297d69e7ec
[LoopDeletion] Update exits correctly when multiple duplicate edges from an exiting block

Summary:
Currently, we incorrectly update exit blocks of loops when there are multiple
edges from a single exiting block to the exit block. This can happen when we
have switches as the terminator of the exiting blocks.
The fix here is to correctly update the phi nodes in the exit block, and remove
all incoming values *except* for one which is from the preheader.

Note: Currently, this error can manifest only while deleting non-executed loops. However, it
is possible to trigger this error in invariant loops, once we enhance the logic
around the exit conditions for the loop check.

Reviewers: chandlerc, dberlin, sanjoy, efriedma

Reviewed by: efriedma

Subscribers: mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306048 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopDeletion.cpp
test/Transforms/LoopDeletion/unreachable-loops.ll