From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31053 invoked by alias); 15 Jan 2013 10:57:17 -0000 Received: (qmail 31024 invoked by uid 22791); 15 Jan 2013 10:57:16 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Jan 2013 10:57:08 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 15 Jan 2013 10:56:47 +0000 Received: from [10.1.69.67] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 15 Jan 2013 10:56:47 +0000 Message-ID: <50F535EE.4030509@arm.com> Date: Tue, 15 Jan 2013 10:57:00 -0000 From: Richard Earnshaw User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: "Joseph S. Myers" CC: "gcc-patches@gcc.gnu.org" Subject: Re: Fix Thumb-1 jump table alignment length calculation (PR target/43961) References: In-Reply-To: X-MC-Unique: 113011510564711801 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00772.txt.bz2 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 > Mikael Pettersson > > 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.