[PATCH] D150009: [AArch64CompressJumpTables] Prevent compression when block alignment is bigger than function alignment.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 10:49:16 PDT 2023
efriedma added a comment.
If we have the maximum size of each block, and the alignment of each block, we can compute a conservative estimate of the layout of the function:
-- block1 offset
block1 instruction size estimate
block2 padding estimate (alignment - 4)
--block2 offset
block1 instruction size estimate
block3 padding estimate (alignment - 4)
--block3 offset
[...]
The actual distance between two of the block offsets will always be less than an estimate computed using simple subtraction: there isn't any actual alignment computation involved, so blocks can't appear closer than they actually are in either direction.
Looking more closely, though, it looks like it doesn't actually work that way at the moment, though: instead of using an alignment estimate, it uses alignTo(). That's probably wrong; I think getInstSizeInBytes is a conservative estimate in some cases.
So the right fix is instead of:
if (Alignment == Align(1))
AlignedOffset = Offset;
else
AlignedOffset = alignTo(Offset, Alignment);
We should do:
if (Alignment <= Align(4))
AlignedOffset = Offset;
else
AlignedOffset = Offset + Alignment.value() - 4;
That should solve the issue without specifically referencing the function's alignment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150009/new/
https://reviews.llvm.org/D150009
More information about the llvm-commits
mailing list