[PATCH] D113912: [JITLink] Fix splitBlock if there are symbols span across the boundary
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 12:52:42 PST 2021
steven_wu updated this revision to Diff 387369.
steven_wu added a comment.
Update the patch to trust user's action and update symbols to fit in the new block
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113912/new/
https://reviews.llvm.org/D113912
Files:
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
Index: llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
===================================================================
--- llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
+++ llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
@@ -493,6 +493,9 @@
false, false);
auto &S4 = G.addDefinedSymbol(B1, 12, "S4", 4, Linkage::Strong,
Scope::Default, false, false);
+ // Add a symbol that extends beyond the split.
+ auto &S5 = G.addDefinedSymbol(B1, 0, "S5", 16, Linkage::Strong,
+ Scope::Default, false, false);
// Add an extra block, EB, and target symbols, and use these to add edges
// from B1 to EB.
@@ -538,6 +541,11 @@
EXPECT_EQ(&S4.getBlock(), &B1);
EXPECT_EQ(S4.getOffset(), 4U);
+ EXPECT_EQ(&S5.getBlock(), &B2);
+ EXPECT_EQ(S5.getOffset(), 0U);
+ // Size shrinks to fit.
+ EXPECT_EQ(S5.getSize(), 8U);
+
// Check that edges in B1 have been transferred as expected:
// Both blocks should now have two edges each at offsets 0 and 4.
EXPECT_EQ(llvm::size(B1.edges()), 2);
Index: llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
+++ llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
@@ -213,7 +213,12 @@
// Transfer all symbols with offset less than SplitIndex to NewBlock.
while (!BlockSymbols.empty() &&
BlockSymbols.back()->getOffset() < SplitIndex) {
- BlockSymbols.back()->setBlock(NewBlock);
+ auto *Sym = BlockSymbols.back();
+ // If the symbol extends beyond the split, update the size to be within
+ // the new block.
+ if (Sym->getOffset() + Sym->getSize() > SplitIndex)
+ Sym->setSize(SplitIndex - Sym->getOffset());
+ Sym->setBlock(NewBlock);
BlockSymbols.pop_back();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113912.387369.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/589265fc/attachment.bin>
More information about the llvm-commits
mailing list