[PATCH] Assign a low branch weight to ASan's slow path.
Chandler Carruth
chandlerc at google.com
Fri Aug 29 01:57:04 PDT 2014
Adding ASan folks...
Didn't we already look at this Kostya? A bit surprised this wasn't already
the case.
On Fri, Aug 29, 2014 at 1:24 AM, Jonas Wagner <jonas.wagner at epfl.ch> wrote:
> Experiments on the SPEC benchmarks show that the slow path is rarely
> taken, and that branch weights reduce branch misses and overall runtime.
> ---
> lib/Transforms/Instrumentation/AddressSanitizer.cpp | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> index 357b5d5..3ff0a61 100644
> --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> @@ -870,8 +870,11 @@ void AddressSanitizer::instrumentAddress(Instruction
> *OrigIns,
> TerminatorInst *CrashTerm = nullptr;
>
> if (ClAlwaysSlowPath || (TypeSize < 8 * Granularity)) {
> + // We use branch weights for the slow path check, to indicate that
> the slow
> + // path is rarely taken. This seems to be the case for SPEC
> benchmarks.
> TerminatorInst *CheckTerm =
> - SplitBlockAndInsertIfThen(Cmp, InsertBefore, false);
> + SplitBlockAndInsertIfThen(Cmp, InsertBefore, false,
> + MDBuilder(*C).createBranchWeights(1, 100000));
> assert(dyn_cast<BranchInst>(CheckTerm)->isUnconditional());
> BasicBlock *NextBB = CheckTerm->getSuccessor(0);
> IRB.SetInsertPoint(CheckTerm);
> --
> 2.1.0
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140829/e9ada26d/attachment.html>
More information about the llvm-commits
mailing list