LLVM API Documentation

Allocator.cpp
Go to the documentation of this file.
00001 //===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the BumpPtrAllocator interface.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "llvm/Support/Allocator.h"
00015 #include "llvm/Support/Compiler.h"
00016 #include "llvm/Support/DataTypes.h"
00017 #include "llvm/Support/Memory.h"
00018 #include "llvm/Support/Recycler.h"
00019 #include "llvm/Support/raw_ostream.h"
00020 #include <cstring>
00021 
00022 namespace llvm {
00023 
00024 namespace detail {
00025 
00026 void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
00027                                 size_t TotalMemory) {
00028   errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
00029          << "Bytes used: " << BytesAllocated << '\n'
00030          << "Bytes allocated: " << TotalMemory << '\n'
00031          << "Bytes wasted: " << (TotalMemory - BytesAllocated)
00032          << " (includes alignment, etc)\n";
00033 }
00034 
00035 } // End namespace detail.
00036 
00037 void PrintRecyclerStats(size_t Size,
00038                         size_t Align,
00039                         size_t FreeListSize) {
00040   errs() << "Recycler element size: " << Size << '\n'
00041          << "Recycler element alignment: " << Align << '\n'
00042          << "Number of elements free for recycling: " << FreeListSize << '\n';
00043 }
00044 
00045 }