[llvm-dev] armv7 pc-rel bx thumb instruction

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 26 12:25:39 PDT 2017


Hi Jonas,

On 26 July 2017 at 10:52, Jonas Devlieghere via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I'm working on some custom transformation passes that have the side-effect
> of
> significantly increasing the code size. While testing it on some larger,
> real-world code bases, I run into a linker error for armv7 thumb code. The
> particular error I get from ld64 is that "armv7 has no pc-rel bx thumb
> instruction." I've been able to reproduce the problem by taking a random
> thumbv7 bitcode file and cloning functions until the linker fails.

Interesting. It looks like you've got a tail call from Thumb code to
ARM code. The linker would normally turn a BL into a BLX to make this
work, but it's (rightly) reporting that there's no "BX some_func"
instruction (you have to load the destination into a register and jump
there).

If you have control over both functions you probably just want to
compile the destination in Thumb mode (there's hardly ever reason to
use ARM mode these days). But given your circumstances there's a
pretty good chance the ARM code is actually a branch island ld64 is
trying to insert.

Other than that Clang has a "-fno-optimize-sibling-calls" which should
disable tail calls and make things work. I'd suggest reporting a bug
against ld64 too, it should be able to handle this case really.

Cheers.

Tim.


More information about the llvm-dev mailing list