<div class="gmail_extra"><div class="gmail_quote">On Tue, Sep 25, 2012 at 11:45 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank" class="cremed">chandlerc@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div class="im">On Tue, Sep 25, 2012 at 2:50 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank" class="cremed">nicholas@mxc.ca</a>></span> wrote:<br>
</div><div><div class="h5"><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" class="cremed">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" class="cremed">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></blockquote><div><br></div></div></div><div>Also, this doesn't make a lot of sense to me. Worklist is a SetVector, and we insert NewAI into it anyways... Were you trying to do something else here? I don't want to misunderstand the intent of the patch.</div>
</div></div></blockquote><div><br></div><div>Heh, this happens to work with the test case we have because of other factors. It just so happens that this is one of the cases where NewAI == OldAI, and thus isn't automatically re-queued for visiting, and this prevents ever revisiting it. Sorry for the noise, but I understand this now.</div>
<div><br></div><div>That said, I also understand the real problem and fix. I'll be reverting this and applying the full fix momentarily which should cope with the strange sequence of events that led to this.</div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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" target="_blank" class="cremed">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div><br></div>
</blockquote></div><br></div>