[clang] [WIP][Clang] Add __builtin_get_counted_by builtin (PR #102549)
Kees Cook via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 21:25:02 PDT 2024
kees wrote:
> > I'd expect some kind of diagnostic when the specified field doesn't have a corresponding counted_by field.
>
> So there's a complication with that. The use case for this builtin is to automatically set the `count` field during allocation in the Linux kernel. (It could be used elsewhere, but Linux is why we're doing this now.) From my understanding, @kees wants to have a way to get the `count` field without having to change the allocator's prototype. (Is that correct?) That's not currently possible, or at least we haven't found a way to do it yet.
Yup, that's correct. There needs to be a way to programmatically determine what the "counter" variable is so that we don't have to create a separate (and ultimately redundant) allocator API for FAM structs that use "counted_by". It could be entirely automatic. Some more background details are here:
https://lore.kernel.org/lkml/20240807235433.work.317-kees@kernel.org/
https://github.com/llvm/llvm-project/pull/102549
More information about the cfe-commits
mailing list