[llvm] 887f1e4 - [llvm-jitlink] Fix a bug in llvm-jitlink's Slab allocator.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 13 19:28:43 PST 2022
Author: Lang Hames
Date: 2022-02-13T19:28:38-08:00
New Revision: 887f1e49d0629fe870361b00d3cb8fb07374873f
URL: https://github.com/llvm/llvm-project/commit/887f1e49d0629fe870361b00d3cb8fb07374873f
DIFF: https://github.com/llvm/llvm-project/commit/887f1e49d0629fe870361b00d3cb8fb07374873f.diff
LOG: [llvm-jitlink] Fix a bug in llvm-jitlink's Slab allocator.
The slab delta (used to link as if allocated at a specified address) should
remain constant.The update to the delta was accidentally introduced in
962a2479b57f5, but hasn't caused any failures as it only breaks in an obvious
way for multi-file exec uses (our regression tests are all -noexec, and tend to
be single-file).
No testcase here: this is an obscure utility for testing support, and an
uncommon use-case. If the slab allocator is ever moved into LLVM we could add
a unit test to catch this.
Added:
Modified:
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 580ebda97cab5..f3443faf7bc7f 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -557,7 +557,7 @@ class JITLinkSlabAllocator final : public JITLinkMemoryManager {
<< "\n";
});
Seg.WorkingMem = SegAddr.toPtr<char *>();
- Seg.Addr = SegAddr + NextSlabDelta;
+ Seg.Addr = SegAddr + SlabDelta;
SegAddr += alignTo(Seg.ContentSize + Seg.ZeroFillSize, PageSize);
@@ -566,8 +566,6 @@ class JITLinkSlabAllocator final : public JITLinkMemoryManager {
memset(Seg.WorkingMem + Seg.ContentSize, 0, Seg.ZeroFillSize);
}
- NextSlabDelta += SegsSizes->total();
-
if (auto Err = BL.apply()) {
OnAllocated(std::move(Err));
return;
@@ -637,7 +635,7 @@ class JITLinkSlabAllocator final : public JITLinkMemoryManager {
// Calculate the target address delta to link as-if slab were at
// SlabAddress.
if (SlabAddress != ~0ULL)
- NextSlabDelta = ExecutorAddr(SlabAddress) -
+ SlabDelta = ExecutorAddr(SlabAddress) -
ExecutorAddr::fromPtr(SlabRemaining.base());
}
@@ -649,7 +647,7 @@ class JITLinkSlabAllocator final : public JITLinkMemoryManager {
std::mutex SlabMutex;
sys::MemoryBlock SlabRemaining;
uint64_t PageSize = 0;
- int64_t NextSlabDelta = 0;
+ int64_t SlabDelta = 0;
};
Expected<uint64_t> getSlabAllocSize(StringRef SizeString) {
More information about the llvm-commits
mailing list