[llvm] r256735 - Fix a horrible infloop in value tracking in the face of dead code.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 4 00:42:05 PST 2016


On Sun, Jan 3, 2016 at 11:26 PM Chandler Carruth via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: chandlerc
> Date: Mon Jan  4 01:23:12 2016
> New Revision: 256735
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256735&view=rev
> Log:
> Fix a horrible infloop in value tracking in the face of dead code.
>
> Amazingly, we just never triggered this without:
> 1) Moving code around for MetadataTracking so that a certain *different*
>    amount of inlining occurs in the per-TU compile step.
> 2) Then you LTO opt or clang with a bootstrap, and get inlining, loop
>    opts, and GVN line up everything *just* right.
>
> I don't really know how we didn't hit this before. We really need to be
> fuzz testing stuff, it shouldn't be hard to trigger. I'm working on
> crafting a reduced nice test case, and will submit that when I have it,
> but I want to get LTO build bots going again.
>

I've tried reasonably hard to come up with a test case by hand and failed
miserably.

If someone wants to try bugpoint-ing an LTO bitcode of opt, just replace
the loop condition with true and assert that insert always works, and you
should be able to, but I'm not going to have time to dig into this further.
=/


>
> Modified:
>     llvm/trunk/lib/Analysis/ValueTracking.cpp
>
> Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=256735&r1=256734&r2=256735&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
> +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jan  4 01:23:12 2016
> @@ -2830,7 +2830,12 @@ Value *llvm::GetPointerBaseWithConstantO
>                                                const DataLayout &DL) {
>    unsigned BitWidth = DL.getPointerTypeSizeInBits(Ptr->getType());
>    APInt ByteOffset(BitWidth, 0);
> -  while (1) {
> +
> +  // We walk up the defs but use a visited set to handle unreachable
> code. In
> +  // that case, we stop after accumulating the cycle once (not that it
> +  // matters).
> +  SmallPtrSet<Value *, 16> Visited;
> +  while (Visited.insert(Ptr).second) {
>      if (Ptr->getType()->isVectorTy())
>        break;
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160104/fad51dd1/attachment.html>


More information about the llvm-commits mailing list