On 09/29/2016 07:32 PM, Denys Vlasenko wrote:
+#ifdef SUBALIGN_LOG

We want to avoid adding new #defines; existing ones are being converted
to target hooks. I suspect the best way is to record whether an M value
was specified, and override it in the x86 option_override if required.
If that's infeasible for some reason we can revisit this.

+      /* Before -falign-foo=N,M,N2,M2 was introduced, x86 had a tweak.
+     -falign-functions=N with N > 8 was adding secondary alignment.
+     -falign-functions=10 was emitting this before every function:
+        .p2align 4,,9
+        .p2align 3
+     Now this behavior (and more) can be explicitly requested:
+     -falign-functions=16,10,8
+     Retain old behavior if N2 is missing: */
+      else if (a[0].log > SUBALIGN_LOG)
+    a[1].log = SUBALIGN_LOG;

So this would live in i386.c, probably.

Thanks, I'm working on it...

...and I can't find a sane way to achieve it in the way you prefer.
Hooking it into ix86_override_options_after_change()?

Like this?

/* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook.  */

static void
ix86_override_options_after_change (void)
{
  ix86_default_align (&global_options);
}

static void
ix86_default_align (struct gcc_options *opts)
{
  struct align_flags *fa;

  /* -falign-foo without argument: supply one */
  if (opts->x_flag_align_functions && !opts->x_str_align_functions)
    {
      opts->x_str_align_functions = 
processor_target_table[ix86_tune].align_func;
    }

  /* Before -falign-foo=N,M,N2,M2 was introduced, x86 had a tweak.
     -falign-functions=N with N > 8 was adding secondary alignment.
     -falign-functions=10 was emitting this before every function:
                .p2align 4,,9
                .p2align 3
     Retain old behavior if N2 is missing: */

  fa = this_target_flag_state->x_align_functions;
  if (fa[1].log == 0 && fa[0].log > 3)
    fa[1].log = 3;
}

Well, the problem here is that init_alignments() is called
much later than this hook. The

  fa = this_target_flag_state->x_align_functions;
  if (fa[1].log == 0 && fa[0].log > 3)
    fa[1].log = 3;

will not trigger here: x_align_functions[0].log is not yet set!
Just set N2 to 2^3 unconditionally?

  fa = this_target_flag_state->x_align_functions;
  fa[1].log = 3;

This will make any alignment, even none: -falign-functions=1
have 8 byte subalign.

Help?

Reply via email to