[llvm] Implement reserveAllocationSpace for SectionMemoryManager (PR #71968)
Graham Markall via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 17 05:14:43 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:
Perhaps we should clear the `FreeMem` vectors before returning early here? Otherwise, we could reserve no space, but still have some free memory left over from a previous reservation, then end up using that to satisfy a later erroneous request instead of hitting the assert that fails when we try to allocate memory without having reserved it first.
https://github.com/llvm/llvm-project/pull/71968
More information about the llvm-commits
mailing list