[JumpThreading] Track unreachable BBs to avoid processing
authorBrian M. Rzycki <brzycki@gmail.com>
Fri, 16 Mar 2018 15:13:47 +0000 (15:13 +0000)
committerBrian M. Rzycki <brzycki@gmail.com>
Fri, 16 Mar 2018 15:13:47 +0000 (15:13 +0000)
commitf65ddc5fa295fa42bf5c00f988db54ed9d38a882
treee55680e6395cea393be3e393a8d73d30918fc86f
parent9915291ab8141ae5c05d30c9bf0962673ad73280
[JumpThreading] Track unreachable BBs to avoid processing

JumpThreading iterates over F until the IR quiesces. Transforming
unreachable BBs increases compile time and it is also possible to
never stabilize causing JumpThreading to hang. An older attempt at
fixing this problem was D3991 where removeUnreachableBlocks(F)
was called before JumpThreading began. This has a few drawbacks:
 * expensive - the routine attempts to fix up the IR to identify
   additional BBs that can be removed along with unreachable BBs.
 * aggressive - does not identify and preserve the shape of the IR.
   At a minimum it does not preserve loop hierarchies.
 * invasive - altering reachable blocks it may disrupt IR shapes
   that could have otherwise been JumpThreaded.

This patch avoids removeUnreachableBlocks(F) and instead tracks
unreachable BBs in a SmallPtrSet using DominatorTree to validate the
initial state of all BBs. We then rely on subsequent passes to identify
and remove these unreachable blocks from F.

Reviewers: dberlin, sebpop, kuhar, dinesh.d

Reviewed by: sebpop, kuhar

Subscribers: hiraditya, uabelho, llvm-commits

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

llvm-svn: 327713
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/test/Transforms/JumpThreading/pr15851_hang.ll
llvm/test/Transforms/JumpThreading/select.ll