`RedZoneSize` is only read inside `#if LLVM_ADDRESS_SANITIZER_BUILD`. Additionally gate it under `LLVM_ENABLE_ABI_BREAKING_CHECKS` so that release-non-assertions builds don't incur the overhead. To support non-asan build with asan library users, the variable is only omitted in `!LLVM_ENABLE_ABI_BREAKING_CHECKS` builds. `BytesAllocated` is incremented on every Allocate (a hot-path memory read-modify-write) only to back `getBytesAllocated()`. Drop the member. There is a measurable stage2 instruction-count reduction. https://llvm-compile-time-tracker.com/compare.php?from=25a6b5be6853b2c493ef392d41e43dd35ad4839a&to=8ebc975635ad717deb392d20b50f1a1f6bb16054&stat=instructions:u Migrate the in-tree consumers: - TableGen dumpAllocationStats drops the line; the clangd debug log reports getTotalMemory(). - clang's PPMemoryAllocationsTest measures getTotalMemory()/#define; over 1M defines this is 120.06 B/define, matching the prior ~120 B, so the existing bound holds. - lldb's ConstString MemoryStats (https://reviews.llvm.org/D117914) drops bytes_used/bytes_unused Aided by Claude Opus 4.8
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
//===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the BumpPtrAllocator interface.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Support/Allocator.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
namespace llvm {
|
|
|
|
namespace detail {
|
|
|
|
void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t TotalMemory) {
|
|
errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
|
|
<< "Bytes allocated: " << TotalMemory << '\n'
|
|
<< " (includes alignment, etc)\n";
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
void PrintRecyclerStats(size_t Size,
|
|
size_t Align,
|
|
size_t FreeListSize) {
|
|
errs() << "Recycler element size: " << Size << '\n'
|
|
<< "Recycler element alignment: " << Align << '\n'
|
|
<< "Number of elements free for recycling: " << FreeListSize << '\n';
|
|
}
|
|
|
|
} // namespace llvm
|