[ARM] Remove redundant BTI instructions for table jumps
authorJirui Wu <jirui.wu@arm.com>
Thu, 16 Feb 2023 16:28:09 +0000 (16:28 +0000)
committerJirui Wu <jirui.wu@arm.com>
Fri, 24 Feb 2023 10:32:30 +0000 (10:32 +0000)
commitbb0403ae2e8f872369b1ce6f88d42d8bf02b922e
tree25fe15bc42446bf0f16119cc6bc8500bd6b334dd
parentee737ad30fa22256e609279184214f75441acefd
[ARM] Remove redundant BTI instructions for table jumps

A BTI instruction was previously inserted at the beginning of each block
that has its address stored in a jump table. Jump tables only emit
indirect jumps in ARM or Thumb1 modes. However, PACBTI is not supported
in these modes. As a result, BTI instructions emitted by jump tables are
redundant. Removing redundant BTI instructions improves the code size
and prevents potential gadgets.

Differential Revision: https://reviews.llvm.org/D144470
llvm/lib/Target/ARM/ARMBranchTargets.cpp
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll
llvm/test/CodeGen/Thumb2/bti-jump-table.mir
llvm/test/MC/ARM/remove-redundant-bti.ll [new file with mode: 0644]