This is definitely not the correct fix.<div><br></div><div>Note from the lang ref:</div><br>"The 'llvm.memcpy.*' intrinsics copy a block of memory from the source location to the destination location, which are not allowed to overlap."<div>
<br></div><div>We cannot have a memcpy (which is what we have) which has the same source and destination pointers. I'm going to comment on the bug that the problem is producing an invalid memcpy intrinsic call somehow, and the fact that SROA *crashes* on it rather than just nuking the memcpy call completely as an impossibility...</div>
<div><br></div><div>I'm digging into where the hell this memcpy is coming from.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 25, 2012 at 2:50 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nicholas<br>
Date: Tue Sep 25 16:50:37 2012<br>
New Revision: 164636<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=164636&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=164636&view=rev</a><br>
Log:<br>
Revert the business end of r164634, and replace it with a different fix. The<br>
reason we were getting two of the same alloca is because of a memmove/memcpy<br>
which had the same alloca in both the src and dest. Now we detect that case<br>
directly. This has the same testcase as before, but fixes a clang test<br>
CodeGenObjC/exceptions.m which runs clang -O2.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Scalar/SROA.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=164636&r1=164635&r2=164636&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=164636&r1=164635&r2=164636&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Tue Sep 25 16:50:37 2012<br>
@@ -2228,7 +2228,10 @@<br>
     // alloca that should be re-examined after rewriting this instruction.<br>
     if (AllocaInst *AI<br>
           = dyn_cast<AllocaInst>(OtherPtr->stripInBoundsOffsets()))<br>
-      Pass.Worklist.insert(AI);<br>
+      // Don't revisit the alloca if both sides of the memory transfer are<br>
+      // referring to the same alloca.<br>
+      if (AI != &NewAI)<br>
+        Pass.Worklist.insert(AI);<br>
<br>
     if (EmitMemCpy) {<br>
       Value *OurPtr<br>
@@ -3108,12 +3111,6 @@<br>
   if (PromotableAllocas.empty())<br>
     return false;<br>
<br>
-  // Ensure that the list is unique.<br>
-  std::sort(PromotableAllocas.begin(), PromotableAllocas.end());<br>
-  PromotableAllocas.erase(std::unique(PromotableAllocas.begin(),<br>
-                                      PromotableAllocas.end()),<br>
-                          PromotableAllocas.end());<br>
-<br>
   NumPromoted += PromotableAllocas.size();<br>
<br>
   if (DT && !ForceSSAUpdater) {<br>
<br>
<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>
</blockquote></div><br></div>