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