[PATCH] D21079: [esan|cfrag] Disable load/store/memintrinsic instrumentation

Qin Zhao via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 08:51:07 PDT 2016


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

Disables load/store/memintrinsic instrumentation for the cache
fragmentation tool.

Adds ClInstrumentFastpath option to control fastpath instrumentation.

Renames cache_frag_basic.ll to working_set_slow.ll for slowpath
instrumentation test.

Adds the __esan_init check in struct_field_count_basic.ll.

http://reviews.llvm.org/D21079

Files:
  lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
  test/Instrumentation/EfficiencySanitizer/cache_frag_basic.ll
  test/Instrumentation/EfficiencySanitizer/struct_field_count_basic.ll
  test/Instrumentation/EfficiencySanitizer/working_set_slow.ll

Index: test/Instrumentation/EfficiencySanitizer/working_set_slow.ll
===================================================================
--- test/Instrumentation/EfficiencySanitizer/working_set_slow.ll
+++ test/Instrumentation/EfficiencySanitizer/working_set_slow.ll
@@ -1,6 +1,6 @@
-; Test basic EfficiencySanitizer cache frag instrumentation.
+; Test basic EfficiencySanitizer slowpath instrumentation.
 ;
-; RUN: opt < %s -esan -esan-cache-frag -S | FileCheck %s
+; RUN: opt < %s -esan -esan-working-set -esan-instrument-fastpath=false -S | FileCheck %s
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Aligned loads:
@@ -254,6 +254,6 @@
 ; Top-level:
 
 ; CHECK: define internal void @esan.module_ctor()
-; CHECK: call void @__esan_init(i32 1, i8* bitcast ({ i8*, i32, { i8*, i32, i64*, i8** }* }* @1 to i8*))
+; CHECK: call void @__esan_init(i32 2, i8* null)
 ; CHECK: define internal void @esan.module_dtor()
-; CHECK: call void @__esan_exit(i8* bitcast ({ i8*, i32, { i8*, i32, i64*, i8** }* }* @1 to i8*))
+; CHECK: call void @__esan_exit(i8* null)
Index: test/Instrumentation/EfficiencySanitizer/struct_field_count_basic.ll
===================================================================
--- test/Instrumentation/EfficiencySanitizer/struct_field_count_basic.ll
+++ test/Instrumentation/EfficiencySanitizer/struct_field_count_basic.ll
@@ -93,3 +93,11 @@
 ; CHECK-NEXT:   %k1 = load %struct.A*, %struct.A** %k, align 8
 ; CHECK-NEXT:   %arrayidx13 = getelementptr inbounds %struct.A, %struct.A* %k1, i64 0
 ; CHECK-NEXT:   ret i32 0
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Top-level:
+
+; CHECK: define internal void @esan.module_ctor()
+; CHECK: call void @__esan_init(i32 1, i8* bitcast ({ i8*, i32, { i8*, i32, i64*, i8** }* }* @21 to i8*))
+; CHECK: define internal void @esan.module_dtor()
+; CHECK: call void @__esan_exit(i8* bitcast ({ i8*, i32, { i8*, i32, i64*, i8** }* }* @21 to i8*))
Index: lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -56,6 +56,9 @@
 static cl::opt<bool> ClInstrumentMemIntrinsics(
     "esan-instrument-memintrinsics", cl::init(true),
     cl::desc("Instrument memintrinsics (memset/memcpy/memmove)"), cl::Hidden);
+static cl::opt<bool> ClInstrumentFastpath(
+    "esan-instrument-fastpath", cl::init(true),
+    cl::desc("Instrument fastpath"), 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.
@@ -121,6 +124,11 @@
   if (Options.ToolType == EfficiencySanitizerOptions::ESAN_None)
     Options.ToolType = EfficiencySanitizerOptions::ESAN_CacheFrag;
 
+  // Disable load/store/intrinsics instrumentation if cfrag.
+  if (Options.ToolType == EfficiencySanitizerOptions::ESAN_CacheFrag) {
+    ClInstrumentLoadsAndStores = false;
+    ClInstrumentMemIntrinsics = false;
+  }
   return Options;
 }
 
@@ -591,7 +599,8 @@
                    {IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),
                     ConstantInt::get(IntptrTy, TypeSizeBytes)});
   } else {
-    if (instrumentFastpath(I, DL, IsStore, Addr, Alignment)) {
+    if (ClInstrumentFastpath &&
+        instrumentFastpath(I, DL, IsStore, Addr, Alignment)) {
       NumFastpaths++;
       return true;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21079.59896.patch
Type: text/x-patch
Size: 3506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160607/6309e188/attachment.bin>


More information about the llvm-commits mailing list