2006-10-30 06:08:03 +08:00
|
|
|
//===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2006-10-30 06:08:03 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the BumpPtrAllocator interface.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-12-14 06:21:02 +08:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2009-07-24 12:01:01 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
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
|
|
|
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|