Hi, The gcc.dg/ipa/iinline-attr.c test has been failing for MIPS when using the n32 and n64 ABIs.
These two ABIs imply a 64-bit target, which means that the align_loops, align_jumps, and align_functions flags are set to 8 by default. Because the MIPS backend doesn't use the TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook, those default values will not be propagated through the __optimize__ attribute. This was a known issue (PR target/66015) and was fixed for other architectures. This patch implements the TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE for MIPS and uses it to properly preserve the alignment flags. Tested with mips-mti-elf. Because we are in stage 4, we could temporarily xfail iinline-attr.c for MIPS instead. Regards, Toma gcc/ * config/mips/mips.c (mips_default_align): New function. (mips_set_compression_mode): Use mips_default_align to set alignment flags. (mips_override_options_after_change): New function for the new hook. (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New hook. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index d1deb52..65e105b 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -19360,6 +19360,21 @@ mips_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED, reload_completed = 0; } +/* Provide default values for align_* for 64-bit targets. */ + +static void +mips_default_align (struct gcc_options *opts) +{ + if (TARGET_64BIT) + { + if (opts->x_align_loops == 0) + opts->x_align_loops = 8; + if (opts->x_align_jumps == 0) + opts->x_align_jumps = 8; + if (opts->x_align_functions == 0) + opts->x_align_functions = 8; + } +} /* The last argument passed to mips_set_compression_mode, or negative if the function hasn't been called yet. */ @@ -19450,15 +19465,7 @@ mips_set_compression_mode (unsigned int compression_mode) target_flags &= ~MASK_BRANCHLIKELY; /* Provide default values for align_* for 64-bit targets. */ - if (TARGET_64BIT) - { - if (align_loops == 0) - align_loops = 8; - if (align_jumps == 0) - align_jumps = 8; - if (align_functions == 0) - align_functions = 8; - } + mips_default_align (&global_options); targetm.min_anchor_offset = -32768; targetm.max_anchor_offset = 32767; @@ -19598,6 +19605,14 @@ mips_set_tune (const struct mips_cpu_info *info) } } +/* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE. */ + +static void +mips_override_options_after_change (void) +{ + mips_default_align (&global_options); +} + /* Implement TARGET_OPTION_OVERRIDE. */ static void @@ -22292,6 +22307,8 @@ mips_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE mips_option_override +#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE +#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE mips_override_options_after_change #undef TARGET_LEGITIMIZE_ADDRESS #define TARGET_LEGITIMIZE_ADDRESS mips_legitimize_address