Chris Lattner | b9de903 | 2006-10-29 22:08:03 +0000 | [diff] [blame] | 1 | //===--- Allocator.cpp - Simple memory allocation abstraction -------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Lattner | b9de903 | 2006-10-29 22:08:03 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements the BumpPtrAllocator interface. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Michael Zolotukhin | 67b04bd | 2017-12-13 22:21:02 +0000 | [diff] [blame] | 13 | #include "llvm/Support/Allocator.h" |
Daniel Dunbar | a3d677b | 2009-07-24 04:01:01 +0000 | [diff] [blame] | 14 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | b9de903 | 2006-10-29 22:08:03 +0000 | [diff] [blame] | 15 | |
Reid Kleckner | c2d882d | 2009-07-23 18:34:13 +0000 | [diff] [blame] | 16 | namespace llvm { |
Chris Lattner | b9de903 | 2006-10-29 22:08:03 +0000 | [diff] [blame] | 17 | |
Chandler Carruth | 1cc9023 | 2014-04-14 06:42:56 +0000 | [diff] [blame] | 18 | namespace detail { |
| 19 | |
Chandler Carruth | f5babf9 | 2014-04-14 03:55:11 +0000 | [diff] [blame] | 20 | void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, |
| 21 | size_t TotalMemory) { |
Daniel Dunbar | a3d677b | 2009-07-24 04:01:01 +0000 | [diff] [blame] | 22 | 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 Kleckner | c2d882d | 2009-07-23 18:34:13 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Chandler Carruth | 1cc9023 | 2014-04-14 06:42:56 +0000 | [diff] [blame] | 29 | } // End namespace detail. |
| 30 | |
Reid Kleckner | c2d882d | 2009-07-23 18:34:13 +0000 | [diff] [blame] | 31 | void PrintRecyclerStats(size_t Size, |
| 32 | size_t Align, |
| 33 | size_t FreeListSize) { |
Daniel Dunbar | a3d677b | 2009-07-24 04:01:01 +0000 | [diff] [blame] | 34 | errs() << "Recycler element size: " << Size << '\n' |
| 35 | << "Recycler element alignment: " << Align << '\n' |
| 36 | << "Number of elements free for recycling: " << FreeListSize << '\n'; |
Reid Kleckner | c2d882d | 2009-07-23 18:34:13 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 39 | } |