public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@arm.com>
To: "Joseph S. Myers" <joseph@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: Fix Thumb-1 jump table alignment length calculation (PR target/43961)
Date: Tue, 15 Jan 2013 10:57:00 -0000	[thread overview]
Message-ID: <50F535EE.4030509@arm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1301132235520.1412@digraph.polyomino.org.uk>

On 13/01/13 22:37, Joseph S. Myers wrote:
> Bug 43961 (a regression in 4.5 and later) is the ARM back end
> generating an out-of-range Thumb-1 branch because the calculation (in
> architecture-independent code) of the size of a jump table fails to
> allow for alignment.
>
> Jump table alignment should be allowed for through ADDR_VEC_ALIGN, but
> the ASM back end has a comment /* Jump table alignment is explicit in
> ASM_OUTPUT_CASE_LABEL.  */ and defines ADDR_VEC_ALIGN to 0, so meaning
> that calculations relating to branch ranges fail to allow for the
> alignment.
>
> Bug 43961 has an old patch attached to define ADDR_VEC_ALIGN properly.
> Although that fixes the Thumb-1 issue, it introduces other problems
> for Thumb-2 jump tables because of an interaction between
> ADDR_VEC_ALIGN and CASE_VECTOR_SHORTEN_MODE.  When
> CASE_VECTOR_SHORTEN_MODE is defined, the size of jump table entries,
> and so the alignment required for the jump table, can be changed in
> shorten_branches, but the alignment of the label before the jump table
> has already been computed based on the original mode, and is not then
> updated for the changed mode.  This results in alignment being used
> before a Thumb-2 tbb jump table, which needs to follow the tbb
> instruction immediately.
>
> This patch arranges for shorten_branches to recalculate the alignments
> of labels before jump tables if CASE_VECTOR_SHORTEN_MODE.  The
> recalculation logic may not match the logic for the original
> calculation in all cases - doing so would probably require additional
> information to be stored at the time of the original calculation so it
> is still available for the recalculation.  But I believe the
> recalculated value based on ADDR_VEC_ALIGN should always work - and in
> the cases where, as for the Thumb-2 tbb case, overalignment will not
> work, only the recalculated value is going to be correct.
>
> (There is no testcase in this patch because this sort of thing is
> always extremely sensitive to slight changes in code generation
> between compiler versions and tends to require large,
> version-dependent testcases.)
>
> Tested with no regressions with cross to arm-none-linux-gnueabi (both
> default configuration, testing both -marm and -mthumb, and v7-A, again
> testing both -marm and -mthumb).  OK to commit?
>
> 2013-01-13  Joseph Myers  <joseph@codesourcery.com>
> 	    Mikael Pettersson  <mikpe@it.uu.se>
>
> 	PR target/43961
> 	* config/arm/arm.h (ADDR_VEC_ALIGN): Align SImode jump tables for
> 	Thumb.
> 	(ASM_OUTPUT_CASE_LABEL): Remove.
> 	(ASM_OUTPUT_BEFORE_CASE_LABEL): Define to empty.
> 	* final.c (shorten_branches): Update alignment of labels before
> 	jump tables if CASE_VECTOR_SHORTEN_MODE.
>

OK.

R.


      reply	other threads:[~2013-01-15 10:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-13 22:37 Joseph S. Myers
2013-01-15 10:57 ` Richard Earnshaw [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F535EE.4030509@arm.com \
    --to=rearnsha@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).