diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-04-18 22:44:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-04-18 22:44:46 +0000 |
commit | 28af26d878126d92d8f124cba5143dbd7e4233cd (patch) | |
tree | ce0800ec8b83b1be178442949a843d9790d8c1a2 | |
parent | 75f5cd671bcd979af8cf7ab6e98f0ea090d698f1 (diff) | |
download | bcm5719-llvm-28af26d878126d92d8f124cba5143dbd7e4233cd.tar.gz bcm5719-llvm-28af26d878126d92d8f124cba5143dbd7e4233cd.zip |
Add BumpPtrAllocator::getTotalMemory() to allow clients to query how much memory a BumpPtrAllocator allocated.
llvm-svn: 129727
-rw-r--r-- | llvm/include/llvm/Support/Allocator.h | 3 | ||||
-rw-r--r-- | llvm/lib/Support/Allocator.cpp | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h index c6807099f85..a2ad24ffead 100644 --- a/llvm/include/llvm/Support/Allocator.h +++ b/llvm/include/llvm/Support/Allocator.h @@ -177,6 +177,9 @@ public: unsigned GetNumSlabs() const; void PrintStats() const; + + /// Compute the total physical memory allocated by this allocator. + size_t getTotalMemory() const; }; /// SpecificBumpPtrAllocator - Same as BumpPtrAllocator but allows only diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp index 5e27df6628e..215b0f249d9 100644 --- a/llvm/lib/Support/Allocator.cpp +++ b/llvm/lib/Support/Allocator.cpp @@ -136,6 +136,14 @@ unsigned BumpPtrAllocator::GetNumSlabs() const { return NumSlabs; } +size_t BumpPtrAllocator::getTotalMemory() const { + size_t TotalMemory = 0; + for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) { + TotalMemory += Slab->Size; + } + return TotalMemory; +} + void BumpPtrAllocator::PrintStats() const { unsigned NumSlabs = 0; size_t TotalMemory = 0; |