aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/CodeGen/MachineBasicBlockTest.cpp
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2025-10-09 09:31:16 +0200
committerGitHub <noreply@github.com>2025-10-09 09:31:16 +0200
commitdfa8732d050dea1fd213c7a68a17501febc80794 (patch)
tree2b19155240e63fd3cbf1e87b7d202e7e0c819aa1 /llvm/unittests/CodeGen/MachineBasicBlockTest.cpp
parent5f3714c2214c8f08d2908e140f3c934406ade7d6 (diff)
downloadllvm-dfa8732d050dea1fd213c7a68a17501febc80794.zip
llvm-dfa8732d050dea1fd213c7a68a17501febc80794.tar.gz
llvm-dfa8732d050dea1fd213c7a68a17501febc80794.tar.bz2
[AllocToken, Clang] Infer type hints from sizeof expressions and casts (#156841)
For the AllocToken pass to accurately calculate token ID hints, we need to attach `!alloc_token` metadata for allocation calls. Unlike new expressions, untyped allocation calls (like `malloc`, `calloc`, `::operator new(..)`, `__builtin_operator_new`, etc.) have no syntactic type associated with them. For -fsanitize=alloc-token, type hints are sufficient, and we can attempt to infer the type based on common idioms. When encountering allocation calls (with `__attribute__((malloc))` or `__attribute__((alloc_size(..))`), attach `!alloc_token` by inferring the allocated type from (a) sizeof argument expressions such as `malloc(sizeof(MyType))`, and (b) casts such as `(MyType*)malloc(4096)`. Note that non-standard allocation functions with these attributes are not instrumented by default. Use `-fsanitize-alloc-token-extended` to instrument them as well. Link: https://discourse.llvm.org/t/rfc-a-framework-for-allocator-partitioning-hints/87434 --- This change is part of the following series: 1. https://github.com/llvm/llvm-project/pull/160131 2. https://github.com/llvm/llvm-project/pull/156838 3. https://github.com/llvm/llvm-project/pull/162098 4. https://github.com/llvm/llvm-project/pull/162099 5. https://github.com/llvm/llvm-project/pull/156839 6. https://github.com/llvm/llvm-project/pull/156840 7. https://github.com/llvm/llvm-project/pull/156841 8. https://github.com/llvm/llvm-project/pull/156842
Diffstat (limited to 'llvm/unittests/CodeGen/MachineBasicBlockTest.cpp')
0 files changed, 0 insertions, 0 deletions