[CodeGen] Reuse BlockUtils for -unreachableblockelim pass (NFC)
authorBrian Gesiak <modocache@gmail.com>
Thu, 7 Mar 2019 20:40:55 +0000 (20:40 +0000)
committerBrian Gesiak <modocache@gmail.com>
Thu, 7 Mar 2019 20:40:55 +0000 (20:40 +0000)
commit4e467043fbb5fc9c7c426019c40f9db85d84f31f
tree06a3792aac56440678f3b446b86d5c513c7a85f4
parent9d782f998da5030a29207f5b6e42d0839c4d9954
[CodeGen] Reuse BlockUtils for -unreachableblockelim pass (NFC)

Summary:
The logic in the -unreachableblockelim pass does the following:

1. It traverses the function it's given in depth-first order and
   creates a set of basic blocks that are unreachable from the
   function's entry node.
2. It iterates over each of those unreachable blocks and (1) removes any
   successors' references to the dead block, and (2) replaces any uses of
   instructions from the dead block with null.

The logic in (2) above is identical to what the `llvm::DeleteDeadBlocks`
function from `BasicBlockUtils.h` does. The only difference is that
`llvm::DeleteDeadBlocks` replaces uses of instructions from dead blocks
not with null, but with undef.

Replace the duplicate logic in the -unreachableblockelim pass with a
call to `llvm::DeleteDeadBlocks`. This results in less code but no
functional change (NFC).

Reviewers: mkazantsev, wmi, davidxl, silvas, davide

Reviewed By: davide

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 355634
llvm/lib/CodeGen/UnreachableBlockElim.cpp