This prevents Malloc from allocating the same chunk of memory twice, as
a byproduct of an alignment adjustment which gave the client access to
unallocated memory.
Prior to this patch, the newly-added test failed with:
$ lldb-test ir-memory-map ... ir-memory-map-overlap1.test Command: malloc(size=8, alignment=16) Malloc: address = 0x1000cd000 Command: malloc(size=16, alignment=8) Malloc: address = 0x1000cd010 Command: malloc(size=64, alignment=32) Malloc: address = 0x1000cd020 Command: malloc(size=1, alignment=8) Malloc: address = 0x1000cd060 Command: malloc(size=64, alignment=32) Malloc: address = 0x1000cd080 Command: malloc(size=64, alignment=8) Malloc: address = 0x1000cd0b0 Malloc error: overlapping allocation detected, previous allocation at [0x1000cd080, 0x1000cd0c0)
I don't see anything controversial here (in fact Jim lgtm'd part of this patch off-list), but as this is unfamiliar territory for me I think it'd help to have a proper review. Depends on D47508.
allocation_size = llvm::alignTo(size, alignment)