summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-06-03 22:29:52 +0000
committerDerek Bruening <bruening@google.com>2016-06-03 22:29:52 +0000
commit9ef5772154b3217b7bba462432a618cb96b2e5f9 (patch)
treedc2e0fe7a4d5b1ad0308e5859e1cfaba0c60b29b /llvm/lib/Transforms
parent448dd8c5c64f6557fe395246b2a90e9a89b9eeb7 (diff)
downloadbcm5719-llvm-9ef5772154b3217b7bba462432a618cb96b2e5f9.tar.gz
bcm5719-llvm-9ef5772154b3217b7bba462432a618cb96b2e5f9.zip
[esan|wset] Optionally assume intra-cache-line accesses
Summary: 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. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits Differential Revision: http://reviews.llvm.org/D20978 llvm-svn: 271743
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
index da3e0ca9efd..48a9396a956 100644
--- a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -57,6 +57,14 @@ static cl::opt<bool> ClInstrumentMemIntrinsics(
"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");
@@ -65,6 +73,8 @@ STATISTIC(NumAccessesWithIrregularSize,
STATISTIC(NumIgnoredStructs, "Number of ignored structs");
STATISTIC(NumIgnoredGEPs, "Number of ignored GEP instructions");
STATISTIC(NumInstrumentedGEPs, "Number of instrumented GEP instructions");
+STATISTIC(NumAssumedIntraCacheLine,
+ "Number of accesses assumed to be intra-cache-line");
static const uint64_t EsanCtorAndDtorPriority = 0;
static const char *const EsanModuleCtorName = "esan.module_ctor";
@@ -715,8 +725,12 @@ bool EfficiencySanitizer::instrumentFastpathWorkingSet(
// (and our shadow memory setup assumes 64-byte cache lines).
assert(TypeSize <= 64);
if (!(TypeSize == 8 ||
- (Alignment % (TypeSize / 8)) == 0))
- return false;
+ (Alignment % (TypeSize / 8)) == 0)) {
+ if (ClAssumeIntraCacheLine)
+ ++NumAssumedIntraCacheLine;
+ else
+ return false;
+ }
// We inline instrumentation to set the corresponding shadow bits for
// each cache line touched by the application. Here we handle a single
OpenPOWER on IntegriCloud