[PATCH] D20978: [esan|wset] Optionally assume intra-cache-line accesses

Derek Bruening via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 11:42:30 PDT 2016


bruening created this revision.
bruening added a reviewer: aizatsky.
bruening added subscribers: llvm-commits, eugenis, kcc, zhaoqin, vitalybuka.

Adds an option -esan-assume-intra-cache-line which causes esan to assume
that a single memory access touches just one cache line, even if it is not
aligned, for better performance at a potential accuracy cost.  Experiments
show that the performance difference can be 2x or more, and accuracy loss
is typically negligible, so we turn this on by default.  This currently
applies just to the working set tool.

http://reviews.llvm.org/D20978

Files:
  lib/Transforms/Instrumentation/EfficiencySanitizer.cpp

Index: lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -57,6 +57,14 @@
     "esan-instrument-memintrinsics", cl::init(true),
     cl::desc("Instrument memintrinsics (memset/memcpy/memmove)"), cl::Hidden);
 
+// Experiments show that the performance difference can be 2x or more,
+// and accuracy loss is typically negligible, so we turn this on by default.
+static cl::opt<bool>  ClAssumeIntraCacheLine(
+    "esan-assume-intra-cache-line", cl::init(true),
+    cl::desc("Assume each memory access touches just one cache line, for "
+             "better performance but with a potential loss of accuracy."),
+    cl::Hidden);
+
 STATISTIC(NumInstrumentedLoads, "Number of instrumented loads");
 STATISTIC(NumInstrumentedStores, "Number of instrumented stores");
 STATISTIC(NumFastpaths, "Number of instrumented fastpaths");
@@ -701,7 +709,8 @@
   // and thus larger than a cache line for platforms this tool targets
   // (and our shadow memory setup assumes 64-byte cache lines).
   assert(TypeSize <= 64);
-  if (!(TypeSize == 8 ||
+  if (!ClAssumeIntraCacheLine &&
+      !(TypeSize == 8 ||
         (Alignment % (TypeSize / 8)) == 0))
     return false;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20978.59590.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160603/d7ae9c78/attachment.bin>


More information about the llvm-commits mailing list