blob: f48edac0598ce13ece81ec075fbfbb9b0ca35a10 [file] [log] [blame]
Chris Lattnerb9de9032006-10-29 22:08:03 +00001//===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnerb9de9032006-10-29 22:08:03 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the BumpPtrAllocator interface.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Support/Allocator.h"
Daniel Dunbara3d677b2009-07-24 04:01:01 +000015#include "llvm/Support/raw_ostream.h"
Chris Lattnerb9de9032006-10-29 22:08:03 +000016
Reid Klecknerc2d882d2009-07-23 18:34:13 +000017namespace llvm {
Chris Lattnerb9de9032006-10-29 22:08:03 +000018
Chandler Carruth1cc90232014-04-14 06:42:56 +000019namespace detail {
20
Chandler Carruthf5babf92014-04-14 03:55:11 +000021void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
22 size_t TotalMemory) {
Daniel Dunbara3d677b2009-07-24 04:01:01 +000023 errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
24 << "Bytes used: " << BytesAllocated << '\n'
25 << "Bytes allocated: " << TotalMemory << '\n'
26 << "Bytes wasted: " << (TotalMemory - BytesAllocated)
27 << " (includes alignment, etc)\n";
Reid Klecknerc2d882d2009-07-23 18:34:13 +000028}
29
Chandler Carruth1cc90232014-04-14 06:42:56 +000030} // End namespace detail.
31
Reid Klecknerc2d882d2009-07-23 18:34:13 +000032void PrintRecyclerStats(size_t Size,
33 size_t Align,
34 size_t FreeListSize) {
Daniel Dunbara3d677b2009-07-24 04:01:01 +000035 errs() << "Recycler element size: " << Size << '\n'
36 << "Recycler element alignment: " << Align << '\n'
37 << "Number of elements free for recycling: " << FreeListSize << '\n';
Reid Klecknerc2d882d2009-07-23 18:34:13 +000038}
39
Alexander Kornienkof00654e2015-06-23 09:49:53 +000040}