llvm-project
450db801 - [AllocToken] Add TypeFuncHash and TypeFuncHashPointerSplit modes (#227686)

Commit
53 days ago
[AllocToken] Add TypeFuncHash and TypeFuncHashPointerSplit modes (#227686) AllocToken assigns type-aware tokens to allocation calls, primarily for heap partitioning where allocations of the same type share a token. Beyond heap partitioning, tokens can also be useful as call-site-aware identifiers, where distinguishing allocations of the same type across different functions is desirable. This PR introduces two new token modes, `TypeFuncHash` and `TypeFuncHashPointerSplit`, which combine the hash of the allocated type's name (upper bits) with the hash of the function containing the allocation (lower `Bits/2` bits). `Bits` is `k` if `MaxTokens` is `2^k-1` (e.g. the default `SIZE_MAX`, in which case token IDs are in `[0, MaxTokens]`), and `floor(log2(MaxTokens))` otherwise. In `TypeFuncHashPointerSplit`, the MSB is reserved for the pointer flag. Unknown types use an empty type name and hash to 0. To support this in LLVM, extend `!alloc_token` metadata to accept an optional third operand for the function name, and update the Verifier accordingly. Like the `Increment` and `Random` modes, the new modes are not supported in constant expressions. Clang frontend support is added in a follow-up PR (#228492).
Author
Parents
Loading