From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 1D6523858D35 for ; Mon, 22 May 2023 12:05:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D6523858D35 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-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f3bb395e69so1973302e87.2 for ; Mon, 22 May 2023 05:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684757112; x=1687349112; 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=Fkf2kGWt+pAOfXslcCaO6qB2YzgdC9tbm0+p8qQ3hFU=; b=XxzuTBhouWQe5steA6Z/iXZlSo7FvMeF5n2pWXH1jamLbk2rY4+d95wL8Gp/wQhEzj r/QRe2ewD3l5tishMiujyxY23+bgyDgJG6t3X8M0pb6pj8eNPJudJJLggDohbLn7GYgW I9gQ4LaFTN05NSy0+5rO8pUjmY6ZPbskXBRmIuAKuahbXf9sEW+hUZpGmoOn2zWwQ6TI MMXGTIbIXU/tUibjyfoLQmCrTJ9nAEqudOgqERZTMQWCdlAEZxpp7REmnidajkK8I4/J 0kK9zRxbnAwsAiAEzneux+Bp/gWmKvHXkvfD/RdDFOBVwy8B7TlOGh3O6Js65gw+5YOb 3Hug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684757112; x=1687349112; 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=Fkf2kGWt+pAOfXslcCaO6qB2YzgdC9tbm0+p8qQ3hFU=; b=Bon3a07f5+nXtjzAJSiKlcU9t4CHw9MkdU+UvsNK8zVe50VlZP0pl0gBnu1OC/5WNI piT2qFZ2Scou2qNvV5rTShkICIeRodJwcQvVTMZKgq/2TcwMCwmJlePDW1ImJgdLvfnX iUCZ3kfiG62ovviTK5PTfvJU8fG8k2Og9vz/VNTj/rjOsC1oC440H2/Yljinx9LSn8RY da4UV4UtfAH9SwdlfOD9NZx8j91eyXnJr/NUrdI8DoYV/7X1NUSCs1QBZ0YPYe8D0jVg Ya8nmvbDmWHGTTfc3PUIpdCILZeXAughLEk2OqmoXf5dyGmC/yYMNLYoPw9DTg/XgE1k f1iw== X-Gm-Message-State: AC+VfDyrvrZA7/vNbw/KzvMcZBzCQd7v4XnTER5Ed+aqYiG69QZ34byp gyGCTF7JyB9bp/BYMUMZJzQ/TYmtjWOuzbcYpzk= X-Google-Smtp-Source: ACHHUZ5JzPuthzEma0azZd835IGPmI+JUD9smHcfTrPr9ggOdb7jV+qHVd+JuGtR8rS2kUtqWje7XqxgLe3OQGX5Zl4= X-Received: by 2002:a19:ae0f:0:b0:4d5:8306:4e9a with SMTP id f15-20020a19ae0f000000b004d583064e9amr2763777lfc.46.1684757112240; Mon, 22 May 2023 05:05:12 -0700 (PDT) MIME-Version: 1.0 References: <8089B1FC-D297-4D78-B11D-6FBB4A7CFFBF@microchip.com> In-Reply-To: From: Richard Biener Date: Mon, 22 May 2023 14:05:00 +0200 Message-ID: Subject: Re: [PATCH] avr: Set param_min_pagesize to 0 [PR105523] To: SenthilKumar.Selvaraj@microchip.com Cc: gcc-patches@gcc.gnu.org, chertykov@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,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 Fri, May 19, 2023 at 7:58=E2=80=AFAM wrote: > > On 26/04/23, 5:51 PM, "Richard Biener" > wrote: > > On Wed, Apr 26, 2023 at 12:56 PM > wrote: > > > > > > On Wed, Apr 26, 2023 at 3:15 PM Richard Biener via Gcc-patches > wrote: > > > > > > > > On Wed, Apr 26, 2023 at 11:42 AM Richard Biener > > > > > wr= ote: > > > > > > > > > > On Wed, Apr 26, 2023 at 11:01 AM SenthilKumar.Selvaraj--- via > > > > > Gcc-patches > wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > This patch fixes PR 105523 by setting param_min_pagesize to 0 f= or the > > > > > > avr target. For this target, zero and offsets from zero are per= fectly > > > > > > valid addresses, and the default value of param_min_pagesize en= ds up > > > > > > triggering warnings on valid memory accesses. > > > > > > > > > > I think the proper configuration is to have > > > > > DEFAULT_ADDR_SPACE_ZERO_ADDRESS_VALID > > > > > > > > Err, TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID > > > > > > That worked. Ok for trunk and backporting to 13 and 12 branches > > > (pending regression testing)? > > > > > > OK, but please let Denis time to comment. > > Didn't hear from Denis. When running regression tests with this patch, > I found that some tests with -fdelete-null-pointer-checks were > failing. Commit 19416210b37db0584cd0b3f3b3961324b8973d25 made > -fdelete-null-pointer-checks false by default, while still allowing it > to be overridden from the command line (it was previously > unconditionally false). > > To keep the same behavior, I modified the hook to report zero > addresses as valid only if -fdelete-null-pointer-checks is not set. > With this change, all regression tests pass. > > Ok for trunk and backporting to 13 and 12 branches? I think that's bit backwards - this hook conveys more precise information (it's address-space specific) and it is also more specific. Instead I'd suggest to set the flag to zero in the target like nios2 or msp430 do. In fact we should probably initialize it using this hook (and using the default address space). Richard. > Regards > Senthil > > PR 105523 > > gcc/ChangeLog: > > * config/avr/avr.cc (avr_addr_space_zero_address_valid): > (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): Return true if > flag_delete_null_pointer_checks is not set. > > gcc/testsuite/ChangeLog: > > * gcc.target/avr/pr105523.c: New test. > > > diff --git gcc/config/avr/avr.cc gcc/config/avr/avr.cc > index d5af40f..4c9eb84 100644 > --- gcc/config/avr/avr.cc > +++ gcc/config/avr/avr.cc > @@ -9787,6 +9787,18 @@ avr_addr_space_diagnose_usage (addr_space_t as, lo= cation_t loc) > (void) avr_addr_space_supported_p (as, loc); > } > > +/* Implement `TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID. Zero is a valid > + address in all address spaces. Even in ADDR_SPACE_FLASH1 etc.., > + a zero address is valid and means 0x0000, where RAMPZ is > + set to the appropriate segment value. > + If the user explicitly passes in -fdelete-null-pointer-checks though, > + assume zero addresses are invalid.*/ > + > +static bool > +avr_addr_space_zero_address_valid (addr_space_t as ATTRIBUTE_UNUSED) > +{ > + return flag_delete_null_pointer_checks =3D=3D 0; > +} > > /* Look if DECL shall be placed in program memory space by > means of attribute `progmem' or some address-space qualifier. > @@ -14687,6 +14699,9 @@ avr_float_lib_compare_returns_bool (machine_mode = mode, enum rtx_code) > #undef TARGET_ADDR_SPACE_DIAGNOSE_USAGE > #define TARGET_ADDR_SPACE_DIAGNOSE_USAGE avr_addr_space_diagnose_usage > > +#undef TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID > +#define TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID avr_addr_space_zero_address= _valid > + > #undef TARGET_MODE_DEPENDENT_ADDRESS_P > #define TARGET_MODE_DEPENDENT_ADDRESS_P avr_mode_dependent_address_p > > diff --git gcc/testsuite/gcc.target/avr/pr105523.c gcc/testsuite/gcc.targ= et/avr/pr105523.c > new file mode 100644 > index 0000000..fbbf7bf > --- /dev/null > +++ gcc/testsuite/gcc.target/avr/pr105523.c > @@ -0,0 +1,14 @@ > +/* { dg-do compile } */ > +/* { dg-options "-Os -Wall" } */ > + > +/* Verify no "array subscript 0 is outside array bounds of" is generated > + for accessing memory addresses in the 0-4096 range. */ > + > +typedef __UINT8_TYPE__ uint8_t; > + > +#define SREG (*(volatile uint8_t*) (0x3F + __AVR_SFR_OFFSET__ )) > + > +void bar (void) > +{ > + SREG =3D 0; > +} >