summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Support/Allocator.h2
-rw-r--r--llvm/lib/Support/Allocator.cpp6
2 files changed, 8 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index 527d4c6e2cb..f23a41f17fa 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -23,6 +23,7 @@ public:
MallocAllocator() {}
~MallocAllocator() {}
+ void Reset() {}
void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
void Deallocate(void *Ptr) { free(Ptr); }
void PrintStats() const {}
@@ -38,6 +39,7 @@ public:
BumpPtrAllocator();
~BumpPtrAllocator();
+ void Reset();
void *Allocate(unsigned Size, unsigned Alignment);
void Deallocate(void *Ptr) {}
void PrintStats() const;
diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp
index 234fd41b738..e68c3e26c7d 100644
--- a/llvm/lib/Support/Allocator.cpp
+++ b/llvm/lib/Support/Allocator.cpp
@@ -92,6 +92,12 @@ BumpPtrAllocator::~BumpPtrAllocator() {
((MemRegion*)TheMemory)->Deallocate();
}
+void BumpPtrAllocator::Reset() {
+ ((MemRegion*)TheMemory)->Deallocate();
+ TheMemory = malloc(4096);
+ ((MemRegion*)TheMemory)->Init(4096, 1, 0);
+}
+
void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
MemRegion *MRP = (MemRegion*)TheMemory;
void *Ptr = MRP->Allocate(Size, Align, &MRP);
OpenPOWER on IntegriCloud