Page MenuHomePhabricator

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

Authored by modocache on Mar 6 2019, 5:35 PM.

Details

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).

Diff Detail

Repository
rL LLVM

Event Timeline

modocache created this revision.Mar 6 2019, 5:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2019, 5:35 PM
davide accepted this revision.Mar 7 2019, 11:28 AM

LGTM.

This revision is now accepted and ready to land.Mar 7 2019, 11:28 AM

Thanks for the review!

This revision was automatically updated to reflect the committed changes.