2006-10-30 06:08:03 +08:00
|
|
|
//===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-10-30 06:08:03 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the BumpPtrAllocator interface.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Support/Allocator.h"
|
2013-01-31 17:58:59 +08:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2010-11-30 02:16:10 +08:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Support/Memory.h"
|
2009-07-24 02:34:13 +08:00
|
|
|
#include "llvm/Support/Recycler.h"
|
2009-07-24 12:01:01 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-07-24 02:34:13 +08:00
|
|
|
#include <cstring>
|
2006-10-30 06:08:03 +08:00
|
|
|
|
2009-07-24 02:34:13 +08:00
|
|
|
namespace llvm {
|
2009-07-23 08:30:41 +08:00
|
|
|
|
2014-04-14 14:42:56 +08:00
|
|
|
namespace detail {
|
|
|
|
|
2014-04-14 11:55:11 +08:00
|
|
|
void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
|
|
|
|
size_t TotalMemory) {
|
2009-07-24 12:01:01 +08:00
|
|
|
errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
|
|
|
|
<< "Bytes used: " << BytesAllocated << '\n'
|
|
|
|
<< "Bytes allocated: " << TotalMemory << '\n'
|
|
|
|
<< "Bytes wasted: " << (TotalMemory - BytesAllocated)
|
|
|
|
<< " (includes alignment, etc)\n";
|
2009-07-24 02:34:13 +08:00
|
|
|
}
|
|
|
|
|
2014-04-14 14:42:56 +08:00
|
|
|
} // End namespace detail.
|
|
|
|
|
2009-07-24 02:34:13 +08:00
|
|
|
void PrintRecyclerStats(size_t Size,
|
|
|
|
size_t Align,
|
|
|
|
size_t FreeListSize) {
|
2009-07-24 12:01:01 +08:00
|
|
|
errs() << "Recycler element size: " << Size << '\n'
|
|
|
|
<< "Recycler element alignment: " << Align << '\n'
|
|
|
|
<< "Number of elements free for recycling: " << FreeListSize << '\n';
|
2006-10-30 06:08:03 +08:00
|
|
|
}
|
2008-07-08 06:58:06 +08:00
|
|
|
|
|
|
|
}
|