This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix ARM constant-pool layout calculations under -falign-labels
On Thu, 2 Aug 2012 09:57:40 +0100
Julian Brown <julian@codesourcery.com> wrote:
> On Wed, 1 Aug 2012 14:43:33 -0700
> Roland McGrath <mcgrathr@google.com> wrote:
>
> > Using e.g. -falign-labels=16 on ARM can confuse the constant-pool
> > layout code such that it places pool entries too far away from their
> > referring instructions. This change seems to fix it.
> >
> > I don't have a small test case, only a large one, which I haven't
> > actually tried to get to reproduce on any vanilla ARM target. But
> > the logic of the change seems straightforward and sound.
>
> FWIW, I've hit this issue in the past, and used a patch as follows to
> fix it:
>
> @@ -12015,7 +12025,10 @@ create_fix_barrier (Mfix *fix, HOST_WIDE
> gcc_assert (GET_CODE (from) != BARRIER);
>
> /* Count the length of this insn. */
> - count += get_attr_length (from);
> + if (LABEL_P (from) && (align_jumps > 0 || align_loops > 0))
> + count += MAX (align_jumps, align_loops);
> + else
> + count += get_attr_length (from);
>
> /* If there is a jump table, add its length. */
> tmp = is_jump_table (from);
> @@ -12435,6 +12448,8 @@ arm_reorg (void)
> insn = table;
> }
> }
> + else if (LABEL_P (insn) && (align_jumps > 0 || align_loops >
> 0))
> + address += MAX (align_jumps, align_loops);
> }
>
> fix = minipool_fix_head;
>
> Not sure if that's equivalent, but you might want to check
> -falign-jumps too while you're at it.
(...and -falign-loops. Whoops, misread :-)).