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?) Thanks, Richard