[HeapProf] Clang and LLVM support for heap profiling instrumentation

Authored by tejohnson on Aug 13 2020, 4:29 PM.


[HeapProf] Clang and LLVM support for heap profiling instrumentation

See RFC for background:

Note that the runtime changes will be sent separately (hopefully this
week, need to add some tests).

This patch includes the LLVM pass to instrument memory accesses with
either inline sequences to increment the access count in the shadow
location, or alternatively to call into the runtime. It also changes
calls to memset/memcpy/memmove to the equivalent runtime version.
The pass is modeled on the address sanitizer pass.

The clang changes add the driver option to invoke the new pass, and to
link with the upcoming heap profiling runtime libraries.

Currently there is no attempt to optimize the instrumentation, e.g. to
aggregate updates to the same memory allocation. That will be
implemented as follow on work.

Differential Revision: https://reviews.llvm.org/D85948

Event Timeline

etiotto added inline comments.

Personally I would prefer -fmemory-profiling as the option name.


Formatting. Line too short?


no need for this line.




Can you make this member function const?

Thanks for your comments, @etiotto. I'll address them in the next day or so. Alternate suggestion below for flag.


I'd rather make it an imperative similar to other profile related flags. How about -fmemory-profile ?

@davidxl wdyt?

I am fine with -fmemory-profiler.

I am fine with -fmemory-profiler.

Do you mean -fmemory-profile (my alternate to the suggested -fmemory-profiling)?

I accidentally threw in a third choice :). Yes -fmemory-profile is fine
which is consistent with -fsanitize=