[llvm] Implement reserveAllocationSpace for SectionMemoryManager (PR #71968)

Graham Markall via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 05:23:27 PST 2023


================
@@ -18,6 +18,89 @@
 
 namespace llvm {
 
+bool SectionMemoryManager::hasSpace(const MemoryGroup &MemGroup,
+                                    uintptr_t Size) const {
+  for (const FreeMemBlock &FreeMB : MemGroup.FreeMem) {
+    if (FreeMB.Free.allocatedSize() >= Size)
+      return true;
+  }
+  return false;
+}
+
+void SectionMemoryManager::reserveAllocationSpace(
+    uintptr_t CodeSize, Align CodeAlign, uintptr_t RODataSize,
+    Align RODataAlign, uintptr_t RWDataSize, Align RWDataAlign) {
+  if (CodeSize == 0 && RODataSize == 0 && RWDataSize == 0)
----------------
gmarkall wrote:

Or, is this OK to return early without clearing free memory, on the same grounds that we reuse a previous contiguous block [below](https://github.com/llvm/llvm-project/pull/71968/files#diff-58b356a4f34602c02eed8c5a40839ebbc5149fefa38b6739a87c9b85862bf372R49-R50) if there's enough space in the existing reservation?

https://github.com/llvm/llvm-project/pull/71968


More information about the llvm-commits mailing list