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

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 05:31:56 PDT 2023


hctim wrote:

> 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.

IMHO there's enough templates already floating around in scudo. If there's no plans to add additional callsites, and it seems fine that `getBuffer` can return `uptr*`, seems like a good idea to just remove the template, and make this patch a pure migration from `BufferSize -> NumElements`.


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


More information about the llvm-commits mailing list