[PATCH] D21594: [esan|cfrag] Add counters for struct array accesses

Qin Zhao via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 09:20:07 PDT 2016


zhaoqin added inline comments.

================
Comment at: lib/Transforms/Instrumentation/EfficiencySanitizer.cpp:174
@@ +173,3 @@
+                           unsigned CounterIdx);
+  unsigned getStructCounterSize(StructType *StructTy) {
+    // We use one counter for each struct field and one additional
----------------
zhaoqin wrote:
> aizatsky wrote:
> > It is not clear to me what you are getting by appending counter to the end rather than adding a fixed field to the struct. Wouldn't the code become simpler?
> As I explained in the comment below, I was trying to avoid creating additional variable name for the new counter, so reduce link time, which deduplicates/merges counters based on their names.
To be clear, the struct instance is created for each compilation/translation unit (e.g., x264.cc).
The counter (and all the struct field counters) is for each structure (e.g., struct x264_t). We rely on special name and weak linkage to merge the counters of the same struct from different CUs at link time.
I could create separate counter with special name for each case, but I think an array of counter seems more reasonable, it is also easy to extend without breaking the binary compatibility in the future.
I will try to make the code more clear on that.




http://reviews.llvm.org/D21594





More information about the llvm-commits mailing list