[Lldb-commits] [PATCH] D47551: [IRMemoryMap] Fix the alignment adjustment in Malloc

Vedant Kumar via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 31 13:58:14 PDT 2018


vsk added a comment.

In https://reviews.llvm.org/D47551#1117086, @lhames wrote:

> LGTM.
>
> I haven't looked at process memory management. How hard would your FIXME be to implement?


After looking at this more carefully, I think the FIXME makes a bad prescription. It's based on the assumption that each platform-specific allocator makes use of an efficient API to make aligned allocations. This doesn't generally seem to be true, because the platform-specific allocators rely on mmap().

A better alternative might be to add a new API, `AllocatedMemoryCache::AllocateAlignedMemory(size, alignment)`. You could implement an alignment-aware allocator here, say, by splitting up free memory into a list of buckets (one list per alignment). Next, you could surface the API from `Process`, provided there's a fallback strategy when the allocated memory cache is disabled.

One caveat to all of this is that it might not be worth doing unless fragmentation-related overhead is identified as a bottleneck.

I'll remove the FIXME.


https://reviews.llvm.org/D47551





More information about the lldb-commits mailing list