10b57cec5SDimitry Andric //===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file implements the BumpPtrAllocator interface.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric #include "llvm/Support/Allocator.h"
140b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h"
150b57cec5SDimitry Andric
160b57cec5SDimitry Andric namespace llvm {
170b57cec5SDimitry Andric
180b57cec5SDimitry Andric namespace detail {
190b57cec5SDimitry Andric
printBumpPtrAllocatorStats(unsigned NumSlabs,size_t BytesAllocated,size_t TotalMemory)200b57cec5SDimitry Andric void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
210b57cec5SDimitry Andric size_t TotalMemory) {
220b57cec5SDimitry Andric errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
230b57cec5SDimitry Andric << "Bytes used: " << BytesAllocated << '\n'
240b57cec5SDimitry Andric << "Bytes allocated: " << TotalMemory << '\n'
250b57cec5SDimitry Andric << "Bytes wasted: " << (TotalMemory - BytesAllocated)
260b57cec5SDimitry Andric << " (includes alignment, etc)\n";
270b57cec5SDimitry Andric }
280b57cec5SDimitry Andric
29*fe6060f1SDimitry Andric } // namespace detail
300b57cec5SDimitry Andric
PrintRecyclerStats(size_t Size,size_t Align,size_t FreeListSize)310b57cec5SDimitry Andric void PrintRecyclerStats(size_t Size,
320b57cec5SDimitry Andric size_t Align,
330b57cec5SDimitry Andric size_t FreeListSize) {
340b57cec5SDimitry Andric errs() << "Recycler element size: " << Size << '\n'
350b57cec5SDimitry Andric << "Recycler element alignment: " << Align << '\n'
360b57cec5SDimitry Andric << "Number of elements free for recycling: " << FreeListSize << '\n';
370b57cec5SDimitry Andric }
380b57cec5SDimitry Andric
39*fe6060f1SDimitry Andric } // namespace llvm
40