[PATCH] D35918: [GVNHoist] Factor out reachability to search for anticipable instructions quickly

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 14:15:52 PDT 2017


hiraditya added a comment.

In https://reviews.llvm.org/D35918#830987, @kuhar wrote:

> In https://reviews.llvm.org/D35918#830975, @hiraditya wrote:
>
> > In https://reviews.llvm.org/D35918#829175, @kuhar wrote:
> >
> > > @dberlin, @hiraditya
> > >
> > > In https://reviews.llvm.org/D35918#822192, @dberlin wrote:
> > >
> > > > The graph always has one root, virtual or not.
> > > >  Once kuba's latest patch is committed, it will *always* be virtual, actually.
> > >
> > >
> > > That's actually already the case upstream since r309146 (https://reviews.llvm.org/D35597).
> > >  https://github.com/llvm-mirror/llvm/blob/22072158f353cc89a7821b13a7c3e99daa5be464/include/llvm/Support/GenericDomTreeConstruction.h#L263
> > >  https://github.com/llvm-mirror/llvm/blob/22072158f353cc89a7821b13a7c3e99daa5be464/include/llvm/Support/GenericDomTreeConstruction.h#L307
> >
> >
> > Can you illustrate how to perform a DFS walk on a post-dom tree with your patch. Also, how would I get the (virtual) root node of post-dom tree.
> >
> > Thanks,
>
>
> You can get the virtual root by calling PDT.getNode(nullptr). Then you can use something like `llvm/ADT/DepthFirstIterator.h` or `llvm/ADT/PostOrderIterator.h` to run DFS on it. Implementing a custom DFS should also be easy.


I tried a simple df walk like this, it crashes the compiler for the test cases llvm/test/Transforms/GVNHoist/infinite-loop-indirect.ll, and llvm/test/Transforms/GVNHoist/infinite-loop-direct.ll:

  auto PrevBB = PDT->getNode(nullptr);
  for (auto it = df_begin(PrevBB); it != df_end(PrevBB);
       ++it) {
  }

These test cases are added in this patch.

Thanks,


https://reviews.llvm.org/D35918





More information about the llvm-commits mailing list