xref: /aosp_15_r20/external/llvm/lib/Support/Allocator.cpp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file implements the BumpPtrAllocator interface.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/Allocator.h"
15*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/raw_ostream.h"
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker namespace llvm {
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker namespace detail {
20*9880d681SAndroid Build Coastguard Worker 
printBumpPtrAllocatorStats(unsigned NumSlabs,size_t BytesAllocated,size_t TotalMemory)21*9880d681SAndroid Build Coastguard Worker void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
22*9880d681SAndroid Build Coastguard Worker                                 size_t TotalMemory) {
23*9880d681SAndroid Build Coastguard Worker   errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
24*9880d681SAndroid Build Coastguard Worker          << "Bytes used: " << BytesAllocated << '\n'
25*9880d681SAndroid Build Coastguard Worker          << "Bytes allocated: " << TotalMemory << '\n'
26*9880d681SAndroid Build Coastguard Worker          << "Bytes wasted: " << (TotalMemory - BytesAllocated)
27*9880d681SAndroid Build Coastguard Worker          << " (includes alignment, etc)\n";
28*9880d681SAndroid Build Coastguard Worker }
29*9880d681SAndroid Build Coastguard Worker 
30*9880d681SAndroid Build Coastguard Worker } // End namespace detail.
31*9880d681SAndroid Build Coastguard Worker 
PrintRecyclerStats(size_t Size,size_t Align,size_t FreeListSize)32*9880d681SAndroid Build Coastguard Worker void PrintRecyclerStats(size_t Size,
33*9880d681SAndroid Build Coastguard Worker                         size_t Align,
34*9880d681SAndroid Build Coastguard Worker                         size_t FreeListSize) {
35*9880d681SAndroid Build Coastguard Worker   errs() << "Recycler element size: " << Size << '\n'
36*9880d681SAndroid Build Coastguard Worker          << "Recycler element alignment: " << Align << '\n'
37*9880d681SAndroid Build Coastguard Worker          << "Number of elements free for recycling: " << FreeListSize << '\n';
38*9880d681SAndroid Build Coastguard Worker }
39*9880d681SAndroid Build Coastguard Worker 
40*9880d681SAndroid Build Coastguard Worker }
41