]> granicus.if.org Git - llvm/commit
[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)
commit1c4b1cfc76f80af6d090caa4a411fbbbaf065ffb
tree19b33073d40d3541602d8000e0e7a8aa7eeacc17
parent323ccae6cab5ef73e7331d4044babdf491aec8b1
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355634 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/UnreachableBlockElim.cpp