Allocator.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===--- Allocator.cpp - Simple memory allocation abstraction -------------===//
  2. //
  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
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements the BumpPtrAllocator interface.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "llvm/Support/Allocator.h"
  13. #include "llvm/Support/raw_ostream.h"
  14. namespace llvm {
  15. namespace detail {
  16. void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
  17. size_t TotalMemory) {
  18. errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
  19. << "Bytes used: " << BytesAllocated << '\n'
  20. << "Bytes allocated: " << TotalMemory << '\n'
  21. << "Bytes wasted: " << (TotalMemory - BytesAllocated)
  22. << " (includes alignment, etc)\n";
  23. }
  24. } // namespace detail
  25. void PrintRecyclerStats(size_t Size,
  26. size_t Align,
  27. size_t FreeListSize) {
  28. errs() << "Recycler element size: " << Size << '\n'
  29. << "Recycler element alignment: " << Align << '\n'
  30. << "Number of elements free for recycling: " << FreeListSize << '\n';
  31. }
  32. } // namespace llvm