[llvm-dev] Potential infinite loop in MemorySSAUpdater

Daniel Berlin via llvm-dev llvm-dev at lists.llvm.org
Sat Sep 23 08:57:34 PDT 2017


On Sat, Sep 23, 2017 at 8:38 AM, Godala, Bhargav-reddy via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi,
>
> Can some one explain the intended behaviour of following loop in void
> MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) function.
>
>   while (!FixupList.empty()) {
>     unsigned StartingPHISize = InsertedPHIs.size();
>     fixupDefs(FixupList);
>     FixupList.clear();
>     // Put any new phis on the fixup list, and process them
>     FixupList.append(InsertedPHIs.end() - StartingPHISize,
> InsertedPHIs.end());
>   }
>
> With the latest code on trunk compilation of perlbench SPEC CPU 2017 INT
> benchmark with “-O3 -inline-threshold=1000 and -enable-gvn-hoist” options
> is looping infinitely on the above loop.
>



>
> Above loop never terminates unless elements from InsertedPHIs are removed
> as and when they are processed.
>

Yes, the loop is slightly off.

The intention is to process any new phis added by fixupdefs.
However, it really should be InsertedPHIs.start() + StartingPHISize.
That will insert only the phis that fixupdefs added, and it will terminate
as soon as fixupdefs stops adding phis.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170923/e3b53659/attachment.html>


More information about the llvm-dev mailing list