[llvm] 0c2b09a - [IR] Lazily number instructions for local dominance queries

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 13:13:05 PST 2020


On Thu, Feb 20, 2020 at 1:10 PM Vedant Kumar <vedant_kumar at apple.com> wrote:

> Wdyt of having DominatorTree take advantage of the instruction ordering?
> Istm this is needed to allow various clients in llvm to get rid of special
> handling for block-local queries.
>
> --- a/llvm/lib/IR/Dominators.cpp
> +++ b/llvm/lib/IR/Dominators.cpp
> @@ -138,16 +138,11 @@ bool DominatorTree::dominates(const Instruction *Def,
>      return dominates(Def, UseBB);
>
>    if (DefBB != UseBB)
>      return dominates(DefBB, UseBB);
>
> -  // Loop through the basic block until we find Def or User.
> -  BasicBlock::const_iterator I = DefBB->begin();
> -  for (; &*I != Def && &*I != User; ++I)
> -    /*empty*/;
> -
> -  return &*I == Def;
> +  return Def->comesBefore(User);
>  }
>

 Absolutely! That was the idea, truly I just rebased the old work and
didn't realize this wasn't hooked up.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200220/9c4b965e/attachment.html>


More information about the llvm-commits mailing list