[LLVMdev] ARM Jump table pcrelative relaxation in clang / llc
Tim Northover
t.p.northover at gmail.com
Sun Jul 5 08:53:30 PDT 2015
Hi Eric,
On 5 July 2015 at 07:22, Eric Bentura <ebentura at gmail.com> wrote:
> As a result it seems that the generated machine code is incorrect (as of
> LLVM 3.5): The AsmPrinter generates the following instruction :
> adr r2, .LJTI4_0_0
> when going through the MC streamer, I get a "fatal error: error in backend:
> out of range pc-relative fixup" .
We've fairly recently fixed a bug that looks very similar (r238680,
which was well after 3.6)
> Apparently, the fixup does not hold in the 12 bits we have available. I
> would have expected clang to perform relaxation on this instruction on that
> particular case.
Agreed, whatever's going on it's a bug in the ARM backend.
> Is there a way in the PassManager::runOnFunction to anticipate that so that
> I can generate a IR code that would fit when converted to machine code?
Not as far as I'm aware; since the bug is further back there's no
reason to try and provide such information to earlier passes. The
backend is expected to cope with whatever you give it.
> Strangely enough, this is not happening when using llc to generate the code
> from the bc file, I get the object file.
That's weird. Even with "-filetype=obj" (the bug only occurs when
directly writing an object file)? Not that it really affects anything,
getting the same backend options with llc can be a bit tricky.
> Even though there have been
> improvements since them, I am concerned with the difference of behavior of
> the two tools.
The most common one I find perturbing output is "-mcpu" (even with a
triple), but really there are so many options front-ends can twiddle
that you just have to know what it's doing and copy that.
Cheers.
Tim.
More information about the llvm-dev
mailing list