From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id 6AAEB3858CDB; Wed, 24 May 2023 09:40:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AAEB3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2af2451b3f1so9626381fa.2; Wed, 24 May 2023 02:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684921208; x=1687513208; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DeaYKH3nDnEm76EidhEzjlsLCikgcXWP7RUj9kLBNHs=; b=g3X2aQxYsMGOXPu07Km7JGgAdfVQXoB5hVDfyKebUqyA9QTGXJIV0wsQbb8Tm+qtd1 nWc0L5dpLFZiNUft49F7kak3kXGdIj+ZzE4aQd3SwN0T7qprvQHgxoY0hc+hLWcYE0Hk JHyXtpeIWyk9FXoFfdHYeeTTnK1YujAcoeFeMBde6Pi6xY4bxVpyJwz1+Xc3VbhUixAk MP2z1t+YrUgGNVLX5K5Moar2P+AvUZdpio8iWN6ndmdLFMAmfdviXPWqHK3Os/uIQXeQ mvx3pgl9Z2NKNf/drHb7ipdawWVgpZlUv3cF6+cHCvo2XyQ7MOlO5M/uY3E9Z8NBKLsq xJjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684921208; x=1687513208; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DeaYKH3nDnEm76EidhEzjlsLCikgcXWP7RUj9kLBNHs=; b=SyTSYWoWiTSV1uwMyhtPD/KdP+yYXX/ABh9+5Ibd5kq0iiB2AhI2k4EL4FhGlch58Y +ZaqLMWx/GX0uXK/jmnLI5NEkOcjqP8ADVGgpyZS2dEdcmIIkrkbGJhhzOG24ag0nvpS oBOEFKlZEA4F+TrZFyA+pZp0xzlO6Y1mnh4aDPbF2QWuFprUaRxWvBzeHS+SJEPfJesW GEj/DhbDS+WS33XX/Z7m8RXW8L/DgxPPZBRkuKRub+ZBxeGjE448cLuj+yomAUhAVhn+ XLy7EpE3mW120A2SzThweWEbaXQkKrJfkfcmDkgVpoJWuuBq347F12U40Us9eNmszd71 WIQQ== X-Gm-Message-State: AC+VfDyS9erWGk+w+Z40MDqo5WCH+FktXy/PKOkz0/I35a6wnbuxF833 Iw48vXhCE1A/5An35YkdYTJ9nAB2yb9/y1VNdtc= X-Google-Smtp-Source: ACHHUZ5IyFtjgWyOq/RJYfaM94OzCS0G49/tO8Bmtt9cqpsZt8Gt1xpyoaZA7dq1ScN23IVTmY27PPNInjj/B9yqpsc= X-Received: by 2002:a2e:81c2:0:b0:2a7:653d:166c with SMTP id s2-20020a2e81c2000000b002a7653d166cmr6819196ljg.3.1684921207674; Wed, 24 May 2023 02:40:07 -0700 (PDT) MIME-Version: 1.0 References: <7a3552f0-ac4d-754f-a7ba-cba3ff9a4a41@gjlay.de> <6ecf31c6-1fa2-330d-6744-2a1d013fd530@gjlay.de> In-Reply-To: <6ecf31c6-1fa2-330d-6744-2a1d013fd530@gjlay.de> From: Richard Biener Date: Wed, 24 May 2023 11:38:01 +0200 Message-ID: Subject: Re: [patch]: Implement PR104327 for avr To: Georg-Johann Lay Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, May 23, 2023 at 2:56=E2=80=AFPM Georg-Johann Lay wro= te: > > PR target/104327 not only affects s390 but also avr: > The avr backend pre-sets some options depending on optimization level. > The inliner then thinks that always_inline functions are not eligible > for inlining and terminates with an error. > > Proposing the following patch that implements TARGET_CAN_INLINE_P. > > Ok to apply? > > Johann > > -- > > target/104327: Allow more inlining between different optimization levels. > > avr-common.cc introduces the following options that are set depending > on optimization level: -mgas-isr-prologues, -mmain-is-OS-task and > -fsplit-wide-types-early. The inliner thinks that different options > disallow cross-optimization inlining, so provide can_inline_p. > > gcc/ > PR target/104327 > * config/avr/avr.cc (avr_can_inline_p): New static function. > (TARGET_CAN_INLINE_P): Define to that function. > diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc > index 9fa50ca230d..55b48f63865 100644 > --- a/gcc/config/avr/avr.cc > +++ b/gcc/config/avr/avr.cc > @@ -1018,6 +1018,22 @@ avr_no_gccisr_function_p (tree func) > return avr_lookup_function_attribute1 (func, "no_gccisr"); > } > > + > +/* Implement `TARGET_CAN_INLINE_P'. */ > +/* Some options like -mgas_isr_prologues depend on optimization level, > + and the inliner might think that due to different options, inlining > + is not permitted; see PR104327. */ > + > +static bool > +avr_can_inline_p (tree /* caller */, tree callee) > +{ > + // For now, dont't allow to inline ISRs. If the user actually wants > + // to inline ISR code, they have to turn the body of the ISR into an > + // ordinary function. > + > + return ! avr_interrupt_function_p (callee); I'm not sure if AVR has ISA extensions but the above will likely break things like void __attribute__((target("-mX"))) foo () { asm ("isa X opcode"); stmt-that-generates-X-ISA; } void bar () { if (cpu-has-X) foo (); } if always-inlines are the concern you can use bool always_inline =3D (DECL_DISREGARD_INLINE_LIMITS (callee) && lookup_attribute ("always_inline", DECL_ATTRIBUTES (callee))); /* Do what the user says. */ if (always_inline) return true; return default_target_can_inline_p (caller, callee); > +} > + > /* Implement `TARGET_SET_CURRENT_FUNCTION'. */ > /* Sanity cheching for above function attributes. */ > > @@ -14713,6 +14729,9 @@ avr_float_lib_compare_returns_bool (machine_mode > mode, enum rtx_code) > #undef TARGET_MD_ASM_ADJUST > #define TARGET_MD_ASM_ADJUST avr_md_asm_adjust > > +#undef TARGET_CAN_INLINE_P > +#define TARGET_CAN_INLINE_P avr_can_inline_p > + > struct gcc_target targetm =3D TARGET_INITIALIZER; > > >