On Wed, 4 Jun 2014, Sandra Loosemore wrote:
> On 06/04/2014 06:20 AM, Richard Biener wrote:
> > On Tue, 3 Jun 2014, Richard Sandiford wrote:
> >
> > > Richi suggested just changing the alignment at output time. I assume
> > > that would be a case of replacing the DECL_ALIGN in:
> > >
> > > /* Tell assembler to move to target machine's alignment for functions.
> > > */
> > > align = floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT);
> > > if (align > 0)
> > > {
> > > ASM_OUTPUT_ALIGN (asm_out_file, align);
> > > }
> > >
> > > with a hook. (Is that right?)
> >
> > Yeah, kind of. Of course if DECL_ALIGN on function-decls is "unused"
> > then we may as well initialize it to 1 in tree.c and at an appropriate
> > stage adjust it to the result of a target hook invocation.
> >
> > Appropriate stage would be the above place (which means DECL_ALIGN
> > is essentially "unused" for FUNCTION_DECLs).
> >
> > So ... can you massage the DECL_ALIGN macro to ICE on FUNCTION_DECLs
> > and see where we access it? (generic code will possibly trip on it,
> > but the question is is there any user that cares?)
>
> Well, offhand, I know that one of the places is in handle_aligned_attribute,
> in c-common/c-common.c, where we handle user-specified alignment attributes.
> Here we are potentially both reading and writing the DECL_ALIGN field of a
> FUNCTION_DECL.
Ok, we definitely need to preserve that (documented) behavior. I suppose
it also sets DECL_USER_ALIGN. -falign-functions is probably another
setter of DECL_ALIGN here.
If we add a target hook that may adjust function alignment then it
has to honor any user set alignment, then -falign-functions and
then it may only increase alignment over the default FUNCTION_BOUNDARY.
The point to adjust alignment with the hook may still be output time,
but as we figured it can't simply ignore DECL_ALIGN.
Richard.