Skip to content

Commit 818772a

Browse files
[Orc] Fix remaining memory size of slab allocator
1 parent 403bdd5 commit 818772a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ InProcessMemoryManager::allocate(const JITLinkDylib *JD,
116116

117117
sys::MemoryBlock SegMem(SlabRemaining.base(), SegmentSize);
118118
SlabRemaining = sys::MemoryBlock((char *)SlabRemaining.base() + SegmentSize,
119-
SegmentSize);
119+
SlabRemaining.allocatedSize() - SegmentSize);
120120

121121
// Zero out the zero-fill memory.
122122
memset(static_cast<char *>(SegMem.base()) + Seg.getContentSize(), 0,
@@ -125,6 +125,8 @@ InProcessMemoryManager::allocate(const JITLinkDylib *JD,
125125
// Record the block for this segment.
126126
Blocks[KV.first] = std::move(SegMem);
127127
}
128+
129+
assert(SlabRemaining.allocatedSize() >= 0 && "Mapping exceeds allocation");
128130
return std::unique_ptr<InProcessMemoryManager::Allocation>(
129131
new IPMMAlloc(std::move(Blocks)));
130132
}

0 commit comments

Comments
 (0)