<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="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 class="HOEnZb"><font color="#888888">--<br>
2.1.0<br>
</font></span><div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br></div>