<div dir="ltr">I am actually surprised too :) <div>We've used branch weights in a couple of other places but not here. </div><div>One can easily create a benchmark where these weights will lead to a performance loss,</div>
<div>but the average SPEC numbers clearly show the overal benefit.   </div><div>Let me submit this patch once I confirm the SPEC/ref numbers (the SPEC/test numbers I saw yesterday are very nice)</div><div><br></div><div>--kcc </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 29, 2014 at 1:57 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">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 dir="ltr"><div>Adding ASan folks...</div><div><br></div>Didn't we already look at this Kostya? A bit surprised this wasn't already the case.</div>
<div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 29, 2014 at 1:24 AM, Jonas Wagner <span dir="ltr"><<a href="mailto:jonas.wagner@epfl.ch" target="_blank">jonas.wagner@epfl.ch</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Experiments on the SPEC benchmarks show that the slow path is rarely<br>
taken, and that branch weights reduce branch misses and overall runtime.<br>
---<br>
 lib/Transforms/Instrumentation/AddressSanitizer.cpp | 5 ++++-<br>
 1 file changed, 4 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
index 357b5d5..3ff0a61 100644<br>
--- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
+++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
@@ -870,8 +870,11 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns,<br>
   TerminatorInst *CrashTerm = nullptr;<br>
<br>
   if (ClAlwaysSlowPath || (TypeSize < 8 * Granularity)) {<br>
+    // We use branch weights for the slow path check, to indicate that the slow<br>
+    // path is rarely taken. This seems to be the case for SPEC benchmarks.<br>
     TerminatorInst *CheckTerm =<br>
-        SplitBlockAndInsertIfThen(Cmp, InsertBefore, false);<br>
+        SplitBlockAndInsertIfThen(Cmp, InsertBefore, false,<br>
+            MDBuilder(*C).createBranchWeights(1, 100000));<br>
     assert(dyn_cast<BranchInst>(CheckTerm)->isUnconditional());<br>
     BasicBlock *NextBB = CheckTerm->getSuccessor(0);<br>
     IRB.SetInsertPoint(CheckTerm);<br>
<span><font color="#888888">--<br>
2.1.0<br>
</font></span><div><div><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>