On Tue, 3 Jun 2014, Richard Sandiford wrote:

> Sandra Loosemore <san...@codesourcery.com> writes:
> > Catherine included an earlier version of this patch with the microMIPS 
> > submission a couple years ago:
> >
> > https://gcc.gnu.org/ml/gcc-patches/2012-07/msg00972.html
> >
> > Richard's response was:
> >
> >> Looks like the wrong place to do this.  Please treat this as a separate
> >> patch and get a tree expert to comment.
> >
> > So, here is the separate patch, finally.  :-)  Can a tree expert 
> > comment?  I dug around and didn't see another obvious hook to set 
> > function alignment in a target-specific way depending on attributes of 
> > the function.
> >
> > Besides the new test cases, I regression-tested this on mips-sde-elf 
> > using Mentor's usual assortment of multilibs, specifically including one 
> > for microMIPS.
> 
> OK, I asked Richi on IRC today.  To recap, one of the things I was
> worried about was a test against the address, like (foo & 2) == 0,
> being optimised away before we set the alignment.  Richi pointed
> out that my idea downthread about cgraph_create_node would also be
> too late to avoid that.  Also, looking at it now, I see that we don't
> trust DECL_ALIGN on functions anyway.  From get_object_alignment_2:
> 
>   /* Extract alignment information from the innermost object and
>      possibly adjust bitpos and offset.  */
>   if (TREE_CODE (exp) == FUNCTION_DECL)
>     {
>       /* Function addresses can encode extra information besides their
>        alignment.  However, if TARGET_PTRMEMFUNC_VBIT_LOCATION
>        allows the low bit to be used as a virtual bit, we know
>        that the address itself must be at least 2-byte aligned.  */
>       if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn)
>       align = 2 * BITS_PER_UNIT;
>     }
> 
> And since we use the low bit to encode the ISA mode on MIPS, the upshot
> is that we never assume any alignment for functions.  So there's nothing
> to worry about after all.
> 
> 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?)

Richard.

Reply via email to