[PATCH] D44261: [sanitizer] Align & pad the allocator structures to the cacheline size

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 12:06:00 PST 2018


alekseyshl added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_allocator_primary32.h:273
     u32 rand_state;
-    char padding[kCacheLineSize - 2 * sizeof(uptr) -
-                 sizeof(IntrusiveList<TransferBatch>)];
-  };
-  COMPILER_CHECK(sizeof(SizeClassInfo) == kCacheLineSize);
+  } ALIGNED(kCacheLineSize);
+  COMPILER_CHECK(sizeof(SizeClassInfo) % kCacheLineSize == 0);
----------------
In other places we do "struct ALIGNED(N) TypeName { ...". Why after the struct body here?


================
Comment at: lib/sanitizer_common/sanitizer_allocator_primary32.h:368
   ByteMap possible_regions;
-  SizeClassInfo size_class_info_array[kNumClasses];
+  SizeClassInfo size_class_info_array[kNumClasses] ALIGNED(kCacheLineSize);
 };
----------------
The alignment of an array is the alignment of its elements, no need to specify it here.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D44261





More information about the llvm-commits mailing list