[LLVMdev] ARM Jump table pcrelative relaxation in clang / llc

Tim Northover t.p.northover at gmail.com
Mon Jul 13 09:16:18 PDT 2015


>    There is no processing in there for ARM:ADR. I added the following line:
>            case ARM::ADR:        return ARM::t2ADR;
>    As a result, if relaxation is enabled or bundling is enabled then the instruction is relaxed.

Unfortunately, that's not going to work at runtime, for a couple of reasons:

1. An ARM::ADR instruction is ARM-mode, but ARM::t2ADR is Thumb-mode.
They can't be mixed in the same function (to a first approximation).
It'll be interpreted as an entirely different ARM instruction if a CPU
ever sees it.
2. Even if it did what you were hoping, it only staves of the issue:
t2ADR has a limited range too, it's just longer than ADR.

> I am not sure I am on the right track, but as far as I understand:
> 1)ARM::ADR is not handled by relaxation
> 2)Relaxtion happens under some condition in the ObjectStreamer that I don't fully understand

As suggested by the second problem above, relaxation is not the
correct approach. There is no instruction that we can guarantee will
reach the jump table. There are two plausible ways to fix it (that I
could think of):

1. Enhance ARMConstantIslands.cpp to move the jump table in range if
needed (this is what we did on trunk, see r238680).
2. Fuse the ADR to the jump-table with a pseudo-instruction when
they're first created and expand them much later. This is uglier, but
might be a simpler way to do it.

Of course, the real solution is the usual recommendation to track
trunk wherever possible. Getting stuck on 3.5 is a recipe for ongoing
pain.

Cheers.

Tim.



More information about the llvm-dev mailing list