[compiler-rt] [scudo] Add config option to modify get usable size behavior (PR #158710)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 16:04:42 PDT 2025
================
@@ -706,19 +706,24 @@ class Allocator {
if (!getChunkFromBlock(Block, &Chunk, &Header) &&
!getChunkFromBlock(addHeaderTag(Block), &Chunk, &Header))
return;
- } else {
- if (!getChunkFromBlock(addHeaderTag(Block), &Chunk, &Header))
- return;
- }
- if (Header.State == Chunk::State::Allocated) {
- uptr TaggedChunk = Chunk;
- if (allocatorSupportsMemoryTagging<AllocatorConfig>())
- TaggedChunk = untagPointer(TaggedChunk);
- if (useMemoryTagging<AllocatorConfig>(Primary.Options.load()))
- TaggedChunk = loadTag(Chunk);
- Callback(TaggedChunk, getSize(reinterpret_cast<void *>(Chunk), &Header),
- Arg);
- }
+ } else if (!getChunkFromBlock(addHeaderTag(Block), &Chunk, &Header))
+ return;
+
+ if (Header.State != Chunk::State::Allocated)
+ return;
+
+ uptr TaggedChunk = Chunk;
+ if (allocatorSupportsMemoryTagging<AllocatorConfig>())
+ TaggedChunk = untagPointer(TaggedChunk);
+ uptr Size;
+ if (UNLIKELY(useMemoryTagging<AllocatorConfig>(Primary.Options.load()))) {
+ TaggedChunk = loadTag(Chunk);
+ Size = getSize(reinterpret_cast<void *>(Chunk), &Header);
+ } else if (AllocatorConfig::getExactUsableSize())
+ Size = getSize(reinterpret_cast<void *>(Chunk), &Header);
+ else
+ Size = getUsableSize(reinterpret_cast<void *>(Chunk), &Header);
----------------
ChiaHungDuan wrote:
```suggestion
} else if (AllocatorConfig::getExactUsableSize()) {
Size = getSize(reinterpret_cast<void *>(Chunk), &Header);
} else {
Size = getUsableSize(reinterpret_cast<void *>(Chunk), &Header);
}
```
https://github.com/llvm/llvm-project/pull/158710
More information about the llvm-commits
mailing list