[PATCH] D32564: AArch64: compress jump tables to minimum size needed to reach destinations

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 11:30:32 PDT 2017


On Mon, May 08, 2017 at 09:39:09AM -0700, Tim Northover via llvm-commits wrote:
> On 27 April 2017 at 05:51, Joerg Sonnenberger via Phabricator
> <reviews at reviews.llvm.org> wrote:
> > My primary concern here is that it can make it impossible to
> > hand-patch the resulting assembler. I'm not sure if anyone is doing
> > that, but if I have learned one lesson from pkgsrc development and
> > the set of Linux support patches, it is to expect "yes, someone is
> > really doing" as most likely answer. As such, I would hope for some
> > global option to disable the pass.
> 
> I don't think that's a use case we'd want to support. Certainly not
> based on speculation.

Well, dealing with the large code model has pretty much the same
constraints, so it is effectively something the code has to support
anyway. How does ARM deal with very large local branches? I.e. if you
have a 1GB function and a branch from the beginning to near the end?

> > About putting the jump table into a separate section: that's kind of
> > what GCC is doing. I don't think a jump table has necessarily only
> > one user, but placing it inside the function still looks helpful.
> > That wouldn't conflict with -ffunction-sections or so either.
> 
> Helpful how? It seems like a security risk to me, anything we can get
> out of .text is one less potential gadget and the only benefit of
> putting it there would be if it allowed us to simplify access somehow,
> which I don't think it does.

Helpful in the sense of allowing better addressing. It's not just the
entries in the jump table that can be potentially compressed, but the
load of the jump table address itself might now fit as small immediate +
pc. On most architectures I would expect a clean up pass would work,
i.e. emit the function itself with pseudo-relocations and once you know
the function size, the encoding of the jump table can be decided.
Afterwards the relocations are adjusted as fixup. The generic access
case often requires a register more, but that might be the price to pay?

Joerg


More information about the llvm-commits mailing list