[llvm-dev] LLVM Pass to count reachable BB
Brian M. Rzycki via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 11 08:11:58 PST 2019
If you have access to the dominator analysis (and the data is up-to-date)
you can query if each block is dominated by the entry block of a function.
I used this method to locate (and avoid) unreachable blocks at the
beginning of the JumpThreading pass:
// JumpThreading must not processes blocks unreachable from entry. It's a
// waste of compute time and can potentially lead to hangs.
SmallPtrSet<BasicBlock *, 16> Unreachable;
assert(DTU && "DTU isn't passed into JumpThreading before using it.");
assert(DTU->hasDomTree() && "JumpThreading relies on DomTree to proceed.");
DominatorTree &DT = DTU->getDomTree();
for (auto &BB : F)
And later in the main for loop below (line 378):
On Fri, Jan 11, 2019 at 12:29 AM hameeza ahmed via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> I have code containing conditions and loops. Hence some BB execution are
> determined at run time depending on condition. Now I want to count only
> those BB that are always executed irrespective of condition result means
> reachable. and their execution is evident at compile time.
> How to do this?
> Please help
> Thank You
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev