[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:36:23 PDT 2017


hiraditya added a comment.

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

> In https://reviews.llvm.org/D35918#831066, @hiraditya wrote:
>
> > 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,
>
>
> I tried running loop like yours in a couple of my unittests (`DominatorTreeTest.cpp`) and it seems to work:
>
>   auto PrevBB = PDT->getNode(nullptr);
>   for (auto it = df_begin(PrevBB); it != df_end(PrevBB);
>        ++it) {
>     auto BB = it->getBlock();
>     outs() << (BB ? BB->getName() : "virtual root") << "\n";
>   }
>   
>
> Could you prepare a reduced repro for the crash you saw?
>
> Thanks,
> Kuba


Try  `./bin/opt -S -adce < llvm/test/Transforms/GVNHoist/infinite-loop-direct.ll`

with the following patch. I added the code here for easy reproducibility.

  diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
  index 5b467dc..eb711b9 100644
  --- a/lib/Transforms/Scalar/ADCE.cpp
  +++ b/lib/Transforms/Scalar/ADCE.cpp
  @@ -164,6 +164,10 @@ public:
   }
  
   bool AggressiveDeadCodeElimination::performDeadCodeElimination() {
  +  auto PrevBB = PDT.getNode(nullptr);
  +  for (auto it = df_begin(PrevBB), E = df_end(PrevBB); it != E; ++it) {
  +      dbgs() << "\nTest\n";
  +  }
   


https://reviews.llvm.org/D35918





More information about the llvm-commits mailing list