[PATCH] D108635: [CGP] Fix the crash for combining address mode when having cyclic dependency

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 01:07:29 PDT 2021


skatkov added a comment.

It seems that correct fix should be something different.
The underlying idea of implementation is as follows:
We built phi nodes to get, for example, base address in a point of usage. (in you example it is an offset).
Now we try to find whether there are already existing phi nodes which provide us with the base.
So we try to match all new phi nodes to already existed.
The bug you found actually happened due to we tried to match new phi node to another new phi node and at the end it results in the bug.

So I guess the better fix would be to just ignore new phi nodes when we try to map new phi node to old one.



================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:3731
       for (auto &P : PHI->getParent()->phis()) {
         if (&P == PHI)
           continue;
----------------
I guess the change of this comparison to if (PhiNodesToMatch.count(&P)) should fix your problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108635/new/

https://reviews.llvm.org/D108635



More information about the llvm-commits mailing list