<div dir="ltr">Doh, really sorry.<div><br></div><div>Some one pointed me at the bug, and I didn't realize this review thread was the *same* PR. I ended up fixing this in r202224 by completely removing the check rather than fixing my buggy boolean logic. I also committed a somewhat further reduced test case.</div>
<div><br></div><div>Very sorry for stealing your bug, and thanks for digging through all of the layers here! I know SROA can be challenging to hack on.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, Feb 24, 2014 at 10:20 PM, Karthik Bhat <span dir="ltr"><<a href="mailto:kv.bhat@samsung.com" target="_blank">kv.bhat@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  Hi Chandler,<br>
  Could you please have a look at the patch for final approval? Please let me know your inputs on the patch and if this is good to commit? This fixes PR18615.<br>
  Thanks to Rafael once again for reviewing the patch. Updated the test case as per Rafael's suggesion.<br>
<div class=""><br>
  Regards<br>
  Karthik Bhat<br>
<br>
Hi chandlerc, rafael,<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2759" target="_blank">http://llvm-reviews.chandlerc.com/D2759</a><br>
<br>
CHANGE SINCE LAST DIFF<br>
</div>  <a href="http://llvm-reviews.chandlerc.com/D2759?vs=7303&id=7340#toc" target="_blank">http://llvm-reviews.chandlerc.com/D2759?vs=7303&id=7340#toc</a><br>
<div class=""><br>
Files:<br>
  test/Transforms/SROA/pr18615.ll<br>
  lib/Transforms/Scalar/SROA.cpp<br>
<br>
Index: test/Transforms/SROA/pr18615.ll<br>
===================================================================<br>
--- test/Transforms/SROA/pr18615.ll<br>
+++ test/Transforms/SROA/pr18615.ll<br>
</div>@@ -0,0 +1,23 @@<br>
+; In this test case we are just checking that sroa transformation<br>
+; doesn't result in crash as reported in PR18615 hence disabling output.<br>
+<br>
+; RUN: opt < %s -early-cse -instcombine -sroa -disable-output -S<br>
+; RUN: opt < %s -early-cse -sroa -disable-output -S<br>
<div class="im HOEnZb">+<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>
+<br>
+%struct.S0 = type { i32, i32, i32 }<br>
+<br>
+define void @fn1() {<br>
+entry:<br>
+  %b = alloca i32, align 4<br>
+  %f = alloca [1 x %struct.S0], align 4<br>
+  %arrayidx = getelementptr inbounds [1 x %struct.S0]* %f, i32 0, i64 0<br>
+  %arrayidx1 = getelementptr inbounds [1 x %struct.S0]* %f, i32 0, i64 -1<br>
+  %tmp1 = bitcast %struct.S0* %arrayidx to i8*<br>
+  %tmp2 = bitcast %struct.S0* %arrayidx1 to i8*<br>
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 12, i32 4, i1 false)<br>
+  ret void<br>
+}<br>
+<br>
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1)<br>
</div><div class="im HOEnZb">Index: lib/Transforms/Scalar/SROA.cpp<br>
===================================================================<br>
--- lib/Transforms/Scalar/SROA.cpp<br>
+++ lib/Transforms/Scalar/SROA.cpp<br>
</div><div class="HOEnZb"><div class="h5">@@ -473,12 +473,13 @@<br>
     if (!IsOffsetKnown)<br>
       return PI.setAborted(&II);<br>
<br>
-    // This side of the transfer is completely out-of-bounds, and so we can<br>
+    // This side of the transfer is completely out-of-bounds<br>
+    // (i.e. Offest < 0 or Offset >= AllocSize), and so we can<br>
     // nuke the entire transfer. However, we also need to nuke the other side<br>
     // if already added to our partitions.<br>
     // FIXME: Yet another place we really should bypass this when<br>
     // instrumenting for ASan.<br>
-    if (!Offset.isNegative() && Offset.uge(AllocSize)) {<br>
+    if (Offset.isNegative() || Offset.uge(AllocSize)) {<br>
       SmallDenseMap<Instruction *, unsigned>::iterator MTPI = MemTransferSliceMap.find(&II);<br>
       if (MTPI != MemTransferSliceMap.end())<br>
         S.Slices[MTPI->second].kill();<br>
</div></div><br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>