[AArch64CompressJumpTables] Prevent over-compression caused by invalid alignment.
authorPaul Walker <paul.walker@arm.com>
Tue, 6 Jun 2023 17:21:16 +0000 (18:21 +0100)
committerPaul Walker <paul.walker@arm.com>
Thu, 15 Jun 2023 12:38:20 +0000 (12:38 +0000)
commit31c485c99024edf267b505070f87473fd397eb6a
tree464079db7331e01a3b51628245b836e1cc7a7294
parenta7e7d34dc1ce35afdcd813348a7254ddfe13698a
[AArch64CompressJumpTables] Prevent over-compression caused by invalid alignment.

AArch64CompressJumpTables assumes it can calculate exact block
offsets. This assumption is bogus because getInstSizeInBytes()
only returns an upper bound rather than an exact size. The
assumption is also invalid when a block alignment is bigger than
the function's alignment.

To mitigate both scenarios this patch changes the algorithm to
compute the maximum upper bound for all block offsets. This is
pessimistic but safe because all offsets are treated as unsigned.

Differential Revision: https://reviews.llvm.org/D150009
llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
llvm/test/CodeGen/AArch64/jump-table-compress.mir