[lld][ARM] don't use short thumb thunks if no branch range extension
authorTies Stuij <ties@stuij.se>
Mon, 9 Jan 2023 11:06:00 +0000 (11:06 +0000)
committerTies Stuij <ties@stuij.se>
Mon, 9 Jan 2023 11:45:49 +0000 (11:45 +0000)
commit747fc27ee44d934bc25ecc7a62b0c87fc3af1fd0
tree2267f442ebddb2a84f231988c278e6ae20285749
parent1f11d1bd1261f8126b1d04faa9231cab87633e66
[lld][ARM] don't use short thumb thunks if no branch range extension

In ThumbThunk::isCompatibleWith, we check if we can use short thunks if we are
within branch range. However these short thumb thunks will generate b.w
instructions, and these are not available on pre branch range extension
architectures.

On these architectures (v4, v5, and most of v6), we could replace the b.w with a
Thumb b (2) instruction, but that would in an ideal situation only give us an
extra range of 2048 bytes on top of the 4MB range of a BL, if a thunk section
happens to be placed on the outer range of a BL and the stars are aligned. It
doesn't seem worth it.

What would be worth it is a state change to Arm and a subsequent branch to
either Arm or Thumb code. But that's the subject of another patch.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D140633
lld/ELF/Thunks.cpp
lld/test/ELF/arm-thumb-range-thunk-os-no-ext.s [new file with mode: 0644]