[PATCH] D21351: [esan|cfrag] Minor cfrag report adjustment

Qin Zhao via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 15:14:46 PDT 2016


zhaoqin updated this revision to Diff 60771.
zhaoqin added a comment.

add type printing size limit


http://reviews.llvm.org/D21351

Files:
  lib/esan/cache_frag.cpp

Index: lib/esan/cache_frag.cpp
===================================================================
--- lib/esan/cache_frag.cpp
+++ lib/esan/cache_frag.cpp
@@ -43,8 +43,8 @@
 
 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,16 +58,19 @@
 
 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);
 }
 
@@ -91,12 +94,12 @@
   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]);
+           512/*type print limit*/, Struct->FieldTypeNames[i]);
   }
 }
 
@@ -109,7 +112,8 @@
         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);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21351.60771.patch
Type: text/x-patch
Size: 2415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160614/22404c47/attachment.bin>


More information about the llvm-commits mailing list