<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 11, 2013 at 1:49 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:reid@kleckner.net" target="_blank">reid@kleckner.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: rnk<br>
Date: Tue Dec 10 15:49:28 2013<br>
New Revision: 196973<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=196973&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=196973&view=rev</a><br>
Log:<br>
[asan] Fix the coverage.cc test broken by r196939<br></blockquote><div>Thanks! </div><div>This seems to have fixed (or somehow avoided) a miscopmpile in <a href="http://llvm.org/bugs/show_bug.cgi?id=17907">http://llvm.org/bugs/show_bug.cgi?id=17907</a></div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
It was failing because ASan was adding all of the following to one<br>
function:<br>
- dynamic alloca<br>
- stack realignment<br>
- inline asm<br>
<br>
This patch avoids making the static alloca dynamic when coverage is<br>
used.<br></blockquote><div><br></div><div>Good catch!  </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
ASan should probably not be inserting empty inline asm blobs to inhibit<br>
duplicate tail elimination.<br></blockquote><div><br></div><div>We didn't find any alternative yet. And anyway, inline asm may come from other places. </div><div>E.g. we extensively use it to break compiler optimizations in asan tests. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=196973&r1=196972&r2=196973&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=196973&r1=196972&r2=196973&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Tue Dec 10 15:49:28 2013<br>
@@ -1167,7 +1167,19 @@ bool AddressSanitizer::maybeInsertAsanIn<br>
 //  b) collect usage statistics to help improve Clang coverage design.<br>
 bool AddressSanitizer::InjectCoverage(Function &F) {<br>
   if (!ClCoverage) return false;<br>
-  IRBuilder<> IRB(F.getEntryBlock().getFirstInsertionPt());<br>
+<br>
+  // Skip static allocas at the top of the entry block so they don't become<br>
+  // dynamic when we split the block.  If we used our optimized stack layout,<br>
+  // then there will only be one alloca and it will come first.<br>
+  BasicBlock &Entry = F.getEntryBlock();<br>
+  BasicBlock::iterator IP = Entry.getFirstInsertionPt(), BE = Entry.end();<br>
+  for (; IP != BE; ++IP) {<br>
+    AllocaInst *AI = dyn_cast<AllocaInst>(IP);<br></blockquote><div><br></div><div>Is there a guarantee that the Allocas  are the first insns after getFirstInsertionPt?</div><div>(I know it is usually true). </div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+    if (!AI || !AI->isStaticAlloca())<br>
+      break;<br>
+  }<br>
+<br>
+  IRBuilder<> IRB(IP);<br>
   Type *Int8Ty = IRB.getInt8Ty();<br>
   GlobalVariable *Guard = new GlobalVariable(<br>
       *F.getParent(), Int8Ty, false, GlobalValue::PrivateLinkage,<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></div>