[CodeGen] Reuse BlockUtils for -unreachableblockelim pass (NFC)

Authored by modocache on Mar 7 2019, 12:40 PM.


[CodeGen] Reuse BlockUtils for -unreachableblockelim pass (NFC)

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