[compiler-rt] [scudo] Make BufferPool typed and always express sizes in terms of element count (PR #66896)

Fabio D'Urso via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 05:27:45 PDT 2023


fabio-d wrote:

Hi @hctim, thanks for reviewing :) I'll reply in reverse order:

2 -> Unfortunately I don't have a nice backstory as I'm not aware of any nasty issues causes by this. :smile: I've just found the mismatch while migrating BufferPool to the new platform abstraction layer (i.e. from `map`/`unmap` to `MemMap`, see #66788)

1 -> Yes, the only user is `RegionPageMap`, in the same `.h` file, and it only instantiates it with `uptr` elements. The idea to use a template came up while discussing with @ChiaHungDuan on whether to fix the issue by uniformly interpreting arguments as a number of bytes or as a number of elements.
While we initially considered always interpreting them as a number of bytes and returning `void*` from `getBuffer`, we realized that that it would have made the class harder to use (because the caller would be responsible for always requesting a size that is multiple of the intended element size) and also to implement (because the underlying storage would have had to be a simple byte array, to avoid aliasing issues, while suitably aligned for the intended type). The conclusion was that requesting the type as a template and always interpreting sizes as number of elements make both things simpler.

https://github.com/llvm/llvm-project/pull/66896


More information about the llvm-commits mailing list