[PATCH] D21342: [esan|cfrag] Add the struct field size array in StructInfo

Qin Zhao via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 21:57:11 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL272988: [esan|cfrag] Add the struct field size array in StructInfo (authored by zhaoqin).

Changed prior to commit:
  http://reviews.llvm.org/D21342?vs=60743&id=61064#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21342

Files:
  compiler-rt/trunk/lib/esan/cache_frag.cpp
  compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp

Index: compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp
===================================================================
--- compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp
+++ compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp
@@ -143,47 +143,47 @@
   // CHECK-NEXT:  Unregister class.C#3#14#13#13:  3 fields
   // CHECK-NEXT:   {{.*}} class C
   // CHECK-NEXT:   {{.*}}  size = 32, count = 5, ratio = 3
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0,  count = 2, type = %struct.anon = type { i32, i32 }
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 8,  count = 2, type = %union.anon = type { double }
-  // CHECK-NEXT:   {{.*}}  # 2: offset = 16, count = 1, type = [10 x i8]
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0,  size = 8,  count = 2, type = %struct.anon = type { i32, i32 }
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 8,  size = 8,  count = 2, type = %union.anon = type { double }
+  // CHECK-NEXT:   {{.*}}  # 2: offset = 16, size = 10, count = 1, type = [10 x i8]
   // CHECK-NEXT:  Unregister struct.anon#2#11#11: 2 fields
   // CHECK-NEXT:   {{.*}} struct anon
   // CHECK-NEXT:   {{.*}}  size = 8, count = 2, ratio = 1
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, count = 1, type = i32
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, count = 1, type = i32
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 1, type = i32
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 1, type = i32
   // CHECK-NEXT:  Unregister union.anon#1#3:      1 fields
   // CHECK-NEXT:  Unregister struct.S#2#11#11:    2 fields
   // CHECK-NEXT:   {{.*}} struct S
   // CHECK-NEXT:   {{.*}}  size = 8, count = 2, ratio = 2
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, count = 2, type = i32
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, count = 0, type = i32
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 2, type = i32
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 0, type = i32
   // CHECK-NEXT:  Unregister struct.D#3#11#11#11: 3 fields
   // CHECK-NEXT:   {{.*}} struct D
   // CHECK-NEXT:   {{.*}}  size = 12, count = 2, ratio = 2
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, count = 1, type = i32
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, count = 1, type = i32
-  // CHECK-NEXT:   {{.*}}  # 2: offset = 8, count = 0, type = i32
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 1, type = i32
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 1, type = i32
+  // CHECK-NEXT:   {{.*}}  # 2: offset = 8, size = 4, count = 0, type = i32
   // CHECK-NEXT: in esan::processCompilationUnitExit
   // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s)
   // CHECK-NEXT: in esan::processCompilationUnitExit
   // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 5 class(es)/struct(s)
   // CHECK-NEXT:  Unregister struct.A#2#11#11:    2 fields
   // CHECK-NEXT:   {{.*}} struct A
   // CHECK-NEXT:   {{.*}}  size = 8, count = 2049, ratio = 2048
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, count = 2048, type = i32
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, count = 1, type = i32
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 2048, type = i32
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 1, type = i32
   // CHECK-NEXT:  Unregister struct.B#2#3#2:      2 fields
   // CHECK-NEXT:   {{.*}} struct B
   // CHECK-NEXT:   {{.*}}  size = 16, count = 2097153, ratio = 2097152
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, count = 1, type = float
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 8, count = 2097152, type = double
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 1, type = float
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 8, size = 8, count = 2097152, type = double
   // CHECK-NEXT:  Unregister union.U#1#3:         1 fields
   // CHECK-NEXT:  Duplicated struct.S#2#11#11:    2 fields
   // CHECK-NEXT:  Unregister struct.D#2#11#11:    2 fields
   // CHECK-NEXT:   {{.*}} struct D
   // CHECK-NEXT:   {{.*}}  size = 8, count = 1, ratio = 1
-  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, count = 1, type = i32
-  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, count = 0, type = i32
+  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 1, type = i32
+  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 0, type = i32
   // CHECK-NEXT: {{.*}}EfficiencySanitizer: total struct field access count = 2099214
 }
 #endif // MAIN
Index: compiler-rt/trunk/lib/esan/cache_frag.cpp
===================================================================
--- compiler-rt/trunk/lib/esan/cache_frag.cpp
+++ compiler-rt/trunk/lib/esan/cache_frag.cpp
@@ -29,6 +29,7 @@
   u32 Size;
   u32 NumFields;
   u32 *FieldOffsets;
+  u32 *FieldSize;
   u64 *FieldCounters;
   const char **FieldTypeNames;
 };
@@ -98,9 +99,9 @@
   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,
-           Struct->FieldOffsets[i], Struct->FieldCounters[i],
-           TypePrintLimit, Struct->FieldTypeNames[i]);
+    Report("   #%2u: offset = %u,\t size = %u,\t count = %llu,\t type = %.*s\n",
+           i, Struct->FieldOffsets[i], Struct->FieldSize[i],
+           Struct->FieldCounters[i], TypePrintLimit, Struct->FieldTypeNames[i]);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21342.61064.patch
Type: text/x-patch
Size: 5431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160617/2a84015a/attachment-0001.bin>


More information about the llvm-commits mailing list