Am 24.05.23 um 11:28 schrieb Richard Biener:
On Tue, May 23, 2023 at 1:25 PM Georg-Johann Lay <a...@gjlay.de> wrote:

This error pops up in the testsuite for avr.

As far as I understand, this is due to target-specific optimization like
in avr-common.cc:

      { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_mgas_isr_prologues, NULL, 1 },
      { OPT_LEVELS_1_PLUS, OPT_mmain_is_OS_task, NULL, 1 },
      // Stick to the "old" placement of the subreg lowering pass.
      { OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types_early, NULL, 1 },

For testcases that have say __attribute__(optimize(0))?  Do you have a specific
example?

It's gcc.c-torture/compile/pr104327.c I came across this when checking
fallout.  That test case occurred for a target, but was put in generic
space so other targets would be notified, too:

/* PR target/104327 */

void foo (int *);

static inline __attribute__((always_inline)) void
bar (int *x)
{
  foo (x);
}

__attribute__((cold, optimize("Os"))) void
baz (int *x)
{
  bar (x);
}

Johann


My question is how to fix this.

The backend does not implement can_inline_p, and adding "Optimization"
to the respective option definition in avr.opt does not help.

I think you'd need to implement the target hook and at least handle
the mismatches of target options you want to allow for inlining,

As I wrote in the other answer, setting target options in attribute
is nor supported.  Target attributes should be diagnosed or even
throw error.

Johann

otherwise the default implementations rejects any mismatch, so
for example when a function has -mgas-isr-prologues but a callee
has not it will never inline that (not even with always-inline I think).

It's actually find to inline anything, anywhere.  I added the condition
on interrupts because they get special prologues. Inlining ISR code in
other functions would work, but its not graat style.

Johann


Richard.

Reply via email to