blob: 718d3fc0d8e1ce514585b2caa9db38177d521aa5 [file] [log] [blame]
Chris Lattnerb9de9032006-10-29 22:08:03 +00001//===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattnerb9de9032006-10-29 22:08:03 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the BumpPtrAllocator interface.
10//
11//===----------------------------------------------------------------------===//
12
Michael Zolotukhin67b04bd2017-12-13 22:21:02 +000013#include "llvm/Support/Allocator.h"
Daniel Dunbara3d677b2009-07-24 04:01:01 +000014#include "llvm/Support/raw_ostream.h"
Chris Lattnerb9de9032006-10-29 22:08:03 +000015
Reid Klecknerc2d882d2009-07-23 18:34:13 +000016namespace llvm {
Chris Lattnerb9de9032006-10-29 22:08:03 +000017
Chandler Carruth1cc90232014-04-14 06:42:56 +000018namespace detail {
19
Chandler Carruthf5babf92014-04-14 03:55:11 +000020void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
21 size_t TotalMemory) {
Daniel Dunbara3d677b2009-07-24 04:01:01 +000022 errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
23 << "Bytes used: " << BytesAllocated << '\n'
24 << "Bytes allocated: " << TotalMemory << '\n'
25 << "Bytes wasted: " << (TotalMemory - BytesAllocated)
26 << " (includes alignment, etc)\n";
Reid Klecknerc2d882d2009-07-23 18:34:13 +000027}
28
Chandler Carruth1cc90232014-04-14 06:42:56 +000029} // End namespace detail.
30
Reid Klecknerc2d882d2009-07-23 18:34:13 +000031void PrintRecyclerStats(size_t Size,
32 size_t Align,
33 size_t FreeListSize) {
Daniel Dunbara3d677b2009-07-24 04:01:01 +000034 errs() << "Recycler element size: " << Size << '\n'
35 << "Recycler element alignment: " << Align << '\n'
36 << "Number of elements free for recycling: " << FreeListSize << '\n';
Reid Klecknerc2d882d2009-07-23 18:34:13 +000037}
38
Alexander Kornienkof00654e2015-06-23 09:49:53 +000039}