summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorQin Zhao <zhaoqin@google.com>2016-06-15 17:27:29 +0000
committerQin Zhao <zhaoqin@google.com>2016-06-15 17:27:29 +0000
commitcd5fe14d89e895b068eab56c77f5a7de3930e041 (patch)
tree51b85dc0a853abdeb8b67d84259df8337ed483c0 /compiler-rt/lib
parent4e7ab67c0b486a2fd1432e8a3317ac3ead1f714c (diff)
downloadbcm5719-llvm-cd5fe14d89e895b068eab56c77f5a7de3930e041.tar.gz
bcm5719-llvm-cd5fe14d89e895b068eab56c77f5a7de3930e041.zip
[esan|cfrag] Minor cfrag report adjustment
Summary: Reports the struct field access info only if it has been used at least once. Adds type printing size limit. Formats the cache_frag.cpp with clang-format. Reviewers: bruening Subscribers: llvm-commits, eugenis, kcc, zhaoqin, vitalybuka, aizatsky, kubabrecka Differential Revision: http://reviews.llvm.org/D21351 llvm-svn: 272810
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/esan/cache_frag.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/compiler-rt/lib/esan/cache_frag.cpp b/compiler-rt/lib/esan/cache_frag.cpp
index a68598f1f93..32a8a4a9b89 100644
--- a/compiler-rt/lib/esan/cache_frag.cpp
+++ b/compiler-rt/lib/esan/cache_frag.cpp
@@ -43,8 +43,8 @@ struct CacheFragInfo {
struct StructCounter {
StructInfo *Struct;
- u64 Count; // The total access count of the struct.
- u64 Ratio; // Difference ratio for the struct layout access.
+ u64 Count; // The total access count of the struct.
+ u64 Ratio; // Difference ratio for the struct layout access.
};
// We use StructHashMap to keep track of an unique copy of StructCounter.
@@ -58,20 +58,24 @@ static Context *Ctx;
static void reportStructSummary() {
// FIXME: provide a better struct field access summary report.
- Report("%s: total struct field access count = %llu\n",
- SanitizerToolName, Ctx->TotalCount);
+ Report("%s: total struct field access count = %llu\n", SanitizerToolName,
+ Ctx->TotalCount);
}
// FIXME: we are still exploring proper ways to evaluate the difference between
// struct field counts. Currently, we use a simple formula to calculate the
// difference ratio: V1/V2.
static inline u64 computeDifferenceRatio(u64 Val1, u64 Val2) {
- if (Val2 > Val1) { Swap(Val1, Val2); }
- if (Val2 == 0) Val2 = 1;
+ if (Val2 > Val1) {
+ Swap(Val1, Val2);
+ }
+ if (Val2 == 0)
+ Val2 = 1;
return (Val1 / Val2);
}
static void reportStructCounter(StructHashMap::Handle &Handle) {
+ const u32 TypePrintLimit = 512;
const char *type, *start, *end;
StructInfo *Struct = Handle->Struct;
// Union field address calculation is done via bitcast instead of GEP,
@@ -91,12 +95,12 @@ static void reportStructCounter(StructHashMap::Handle &Handle) {
end = strchr(start, '#');
CHECK(end != nullptr);
Report(" %s %.*s\n", type, end - start, start);
- Report(" size = %u, count = %llu, ratio = %llu\n",
- Struct->Size, Handle->Count, Handle->Ratio);
+ Report(" size = %u, count = %llu, ratio = %llu\n", Struct->Size,
+ Handle->Count, Handle->Ratio);
for (u32 i = 0; i < Struct->NumFields; ++i) {
- Report(" #%2u: offset = %u,\t count = %llu,\t type = %s\n", i,
+ Report(" #%2u: offset = %u,\t count = %llu,\t type = %.*s\n", i,
Struct->FieldOffsets[i], Struct->FieldCounters[i],
- Struct->FieldTypeNames[i]);
+ TypePrintLimit, Struct->FieldTypeNames[i]);
}
}
@@ -109,7 +113,8 @@ static void computeStructRatio(StructHashMap::Handle &Handle) {
Handle->Struct->FieldCounters[i - 1], Handle->Struct->FieldCounters[i]);
}
Ctx->TotalCount += Handle->Count;
- if (Handle->Ratio >= (u64)getFlags()->report_threshold || Verbosity() >= 1)
+ if (Handle->Ratio >= (u64)getFlags()->report_threshold ||
+ (Verbosity() >= 1 && Handle->Count > 0))
reportStructCounter(Handle);
}
OpenPOWER on IntegriCloud