1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[esan|cfrag] Disable load/store instrumentation for cfrag

Summary:
Adds ClInstrumentFastpath option to control fastpath instrumentation.

Avoids the load/store instrumentation for the cache fragmentation tool.

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.

Reviewers: aizatsky

Subscribers: llvm-commits, bruening, eugenis, kcc, zhaoqin, vitalybuka

Differential Revision: http://reviews.llvm.org/D21079

llvm-svn: 272355
This commit is contained in:
Qin Zhao 2016-06-10 00:48:53 +00:00
parent 7bddaed185
commit b4c774b3be
3 changed files with 20 additions and 8 deletions

View File

@ -56,6 +56,9 @@ static cl::opt<bool> ClInstrumentLoadsAndStores(
static cl::opt<bool> ClInstrumentMemIntrinsics( static cl::opt<bool> ClInstrumentMemIntrinsics(
"esan-instrument-memintrinsics", cl::init(true), "esan-instrument-memintrinsics", cl::init(true),
cl::desc("Instrument memintrinsics (memset/memcpy/memmove)"), cl::Hidden); 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, // Experiments show that the performance difference can be 2x or more,
// and accuracy loss is typically negligible, so we turn this on by default. // and accuracy loss is typically negligible, so we turn this on by default.
@ -591,7 +594,8 @@ bool EfficiencySanitizer::instrumentLoadOrStore(Instruction *I,
{IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()), {IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),
ConstantInt::get(IntptrTy, TypeSizeBytes)}); ConstantInt::get(IntptrTy, TypeSizeBytes)});
} else { } else {
if (instrumentFastpath(I, DL, IsStore, Addr, Alignment)) { if (ClInstrumentFastpath &&
instrumentFastpath(I, DL, IsStore, Addr, Alignment)) {
NumFastpaths++; NumFastpaths++;
return true; return true;
} }
@ -708,8 +712,8 @@ bool EfficiencySanitizer::instrumentFastpathCacheFrag(Instruction *I,
const DataLayout &DL, const DataLayout &DL,
Value *Addr, Value *Addr,
unsigned Alignment) { unsigned Alignment) {
// TODO(bruening): implement a fastpath for aligned accesses // Do nothing.
return false; return true; // Return true to avoid slowpath instrumentation.
} }
bool EfficiencySanitizer::instrumentFastpathWorkingSet( bool EfficiencySanitizer::instrumentFastpathWorkingSet(

View File

@ -1,6 +1,6 @@
; Test basic EfficiencySanitizer struct field count instrumentation. ; Test basic EfficiencySanitizer struct field count instrumentation.
; ;
; RUN: opt < %s -esan -esan-cache-frag -esan-instrument-loads-and-stores=false -esan-instrument-memintrinsics=false -S | FileCheck %s ; RUN: opt < %s -esan -esan-cache-frag -S | FileCheck %s
%struct.A = type { i32, i32 } %struct.A = type { i32, i32 }
%union.U = type { double } %union.U = type { double }
@ -93,3 +93,11 @@ entry:
; CHECK-NEXT: %k1 = load %struct.A*, %struct.A** %k, align 8 ; 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: %arrayidx13 = getelementptr inbounds %struct.A, %struct.A* %k1, i64 0
; CHECK-NEXT: ret i32 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*))

View File

@ -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: ; Aligned loads:
@ -254,6 +254,6 @@ entry:
; Top-level: ; Top-level:
; CHECK: define internal void @esan.module_ctor() ; 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: 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)