diff options
author | Marco Elver <elver@google.com> | 2025-10-08 21:58:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-08 21:58:37 +0200 |
commit | 6359980f5b555f95429139c2e2e9530d75d4e78f (patch) | |
tree | 73a5007dfa0c28d377bcd04bfb4b48cfa27f89b2 /llvm/lib/IR/Verifier.cpp | |
parent | 9527f9338f9d116b6eaf5771b961ed0210119326 (diff) | |
download | llvm-6359980f5b555f95429139c2e2e9530d75d4e78f.zip llvm-6359980f5b555f95429139c2e2e9530d75d4e78f.tar.gz llvm-6359980f5b555f95429139c2e2e9530d75d4e78f.tar.bz2 |
[AllocToken, Clang] Implement TypeHashPointerSplit mode (#156840)
Implement the TypeHashPointerSplit mode: This mode assigns a token ID
based on the hash of the allocated type's name, where the top half
ID-space is reserved for types that contain pointers and the bottom half
for types that do not contain pointers.
This mode with max tokens of 2 (`-falloc-token-max=2`) may also
be valuable for heap hardening strategies that simply separate pointer
types from non-pointer types.
Make it the new default mode.
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/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 71a8a38..c9ff86b 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -5398,8 +5398,10 @@ void Verifier::visitCapturesMetadata(Instruction &I, const MDNode *Captures) { void Verifier::visitAllocTokenMetadata(Instruction &I, MDNode *MD) { Check(isa<CallBase>(I), "!alloc_token should only exist on calls", &I); - Check(MD->getNumOperands() == 1, "!alloc_token must have 1 operand", MD); + Check(MD->getNumOperands() == 2, "!alloc_token must have 2 operands", MD); Check(isa<MDString>(MD->getOperand(0)), "expected string", MD); + Check(mdconst::dyn_extract_or_null<ConstantInt>(MD->getOperand(1)), + "expected integer constant", MD); } /// verifyInstruction - Verify that an instruction is well formed. |