<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Jan 3, 2016 at 11:26 PM Chandler Carruth via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chandlerc<br>
Date: Mon Jan  4 01:23:12 2016<br>
New Revision: 256735<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=256735&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=256735&view=rev</a><br>
Log:<br>
Fix a horrible infloop in value tracking in the face of dead code.<br>
<br>
Amazingly, we just never triggered this without:<br>
1) Moving code around for MetadataTracking so that a certain *different*<br>
   amount of inlining occurs in the per-TU compile step.<br>
2) Then you LTO opt or clang with a bootstrap, and get inlining, loop<br>
   opts, and GVN line up everything *just* right.<br>
<br>
I don't really know how we didn't hit this before. We really need to be<br>
fuzz testing stuff, it shouldn't be hard to trigger. I'm working on<br>
crafting a reduced nice test case, and will submit that when I have it,<br>
but I want to get LTO build bots going again.<br></blockquote><div><br></div><div>I've tried reasonably hard to come up with a test case by hand and failed miserably.</div><div><br></div><div>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. =/</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/lib/Analysis/ValueTracking.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=256735&r1=256734&r2=256735&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=256735&r1=256734&r2=256735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jan  4 01:23:12 2016<br>
@@ -2830,7 +2830,12 @@ Value *llvm::GetPointerBaseWithConstantO<br>
                                               const DataLayout &DL) {<br>
   unsigned BitWidth = DL.getPointerTypeSizeInBits(Ptr->getType());<br>
   APInt ByteOffset(BitWidth, 0);<br>
-  while (1) {<br>
+<br>
+  // We walk up the defs but use a visited set to handle unreachable code. In<br>
+  // that case, we stop after accumulating the cycle once (not that it<br>
+  // matters).<br>
+  SmallPtrSet<Value *, 16> Visited;<br>
+  while (Visited.insert(Ptr).second) {<br>
     if (Ptr->getType()->isVectorTy())<br>
       break;<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>