HomePhabricator

[Local] Simplify function removeUnreachableBlocks() to avoid (re-)computation.

Description

[Local] Simplify function removeUnreachableBlocks() to avoid (re-)computation.

Two small changes in llvm::removeUnreachableBlocks() to avoid unnecessary (re-)computation.

First, replace the use of count() with find(), which has better time complexity.

Second, because we have already computed the set of dead blocks, replace the second loop over all basic blocks to a loop only over the already computed dead blocks. This simplifies the loop and avoids recomputation.

Patch by Rodrigo Caetano Rocha <rcor.cs@gmail.com>

Reviewers: efriedma, spatel, fhahn, xbolva00

Reviewed By: fhahn, xbolva00

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

Details

Committed
fhahnOct 2 2019, 12:37 AM
Reviewer
fhahn
Differential Revision
D68191: Simplify function llvm::removeUnreachableBlocks() to avoid (re-)computation.
Parents
rL373428: [clang-tidy] Fix for commits rL372706 and rL372711
Branches
Unknown
Tags
Unknown