[PATCH] D19293: [profile] LLVM support for memory-mapping profile counters

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 18:40:52 PDT 2016


vsk added inline comments.

================
Comment at: lib/ProfileData/InstrProfReader.cpp:288
@@ +287,3 @@
+  // occurs when memory-mapping tightly packed sections into the profile.
+  for (; CurrentPos + sizeof(RawInstrProf::Header) <= End;
+       CurrentPos += sizeof(uint64_t)) {
----------------
davidxl wrote:
> Using the for-loop and pattern matching Magic seems weird. Can the paddings be zero filled?
Sorry about that. This is a hacky workaround for a memory bug I introduced in InstrProfilingWriter.c. Should be fixed shortly.

================
Comment at: lib/Transforms/Instrumentation/InstrProfiling.cpp:390
@@ -385,1 +389,3 @@
 
+void InstrProfiling::emitCounterPadding() {
+  auto PageSize = llvm::sys::Process::getPageSize();
----------------
davidxl wrote:
> Should this be conditionally emitted for darwin only?
> 
> Also do you need to emit this padding bytes per module?  Have you considered using linker script to do that?
I'd like to add support for this feature on other platforms, so I didn't introduce a platform check here.

I did consider using a linker script. I decided not to because it would require more frontend changes than I'd like. On Darwin, I think this would require creating an empty padding section, aligning it to a page boundary, and passing in an `-order_file` that places the padding section after the counter section.


http://reviews.llvm.org/D19293





More information about the llvm-commits mailing list