From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 628E73858422 for ; Mon, 11 Mar 2024 07:26:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 628E73858422 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 628E73858422 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710142002; cv=none; b=WA7K7IkroA7l5Fi6R4sHNBgeRRm/X3WmsgCQlN+M9A6mBK4gOTG6F9NmcYiMkqA2vV0iZ4TKFuwcEMSjpvkAY0+uDGiDxtPsGXsMRieNjfUy8fY3F7b1bBUZ288pmipH+H4rZVbhS1UUzLd/cWtMoCrmVDjeXKXKCAVX9O9xd/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710142002; c=relaxed/simple; bh=Gj8O0qHpQWjbRsejP5N9P+CIScUnxgAxXxfJYLChwrs=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ph82s1QR+cMLwFeYogweruRO4uq615Cvg9bSsuE7/5HoxJFw12DUeZBq2LSR7TwyjATadEVNiGAs02VZ7d9p1adktY22fjBfgQzBVXpoBmNfKQTHo6/Mmu9CQVp/wV8mXjVCn8KXRR9QqjXWvMGm2VC4vpQVcMpPBE0TVyVECPo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d109e82bd0so54738081fa.3 for ; Mon, 11 Mar 2024 00:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710141999; x=1710746799; darn=gcc.gnu.org; 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=+dTs+LQunky8uH3m6sQ5w3qdr97pdduui10jZZRiZQg=; b=noSboSfwtT28I04f7lMQDyVZ56nVh5h19SXM3vlCQpUog1GdRZFBianTGFZZd+40r6 EwNLMvDzJq5G1OfYm04FoCZQLB9MO8w1cE0a4vBpJjxC2xmi7spU6dk4jHVwqp+b5gbT /p6bm9yu+opHq2kASzVukrPUMDaLUnrkeUwEsbOZUH281TnIpNTmxHDytXalkAsqkG4l n0RpPQPOlJ+TSH2SxNVzklzYZ3yo9+TSJYE370guzsglzTGxKOe1O906NahThQ86GkGS fsbZy3zWWpM/g5I7GhzhYFk7THb/RqSlF6xzLBaGQIni2BeJFs64H9GeSpeHlzOvwGaN ZgGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710141999; x=1710746799; 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=+dTs+LQunky8uH3m6sQ5w3qdr97pdduui10jZZRiZQg=; b=mt3kw3HujjGkHhVoylzOxgjfMBChoJB4coPkULkThu4DiAwG6JT2LgZpNMl9bMVDSB B4h4AswMZOHPJFG+qhgdYnfk0Bdyxsslg9P17UtE4asfCnH5mbQ8qUVawhvtPrGu7bBM XyFMsJDdWlvuH11jJDnto7T3sCmKclSo8G4KHY62/XG2u1QmLvgqS0Ayqlio8so/o/76 gS+TqfJ6Axwr/HpltjbuOt7aaz/m8pBggKcEnOc6/+3FGVKqwFWyEQKOvwYZXut8G2Mf aLB29AI+wyJpljeq4B2XpJxpB1OO/hwx70CIhfLB6WlsK9KHvrwdjiuK8UGr6AMmVpKC ZUXg== X-Gm-Message-State: AOJu0YyssolyD32mDX+DzM+5I5btqnZPaqpLXAUv7zzU5Um7A2kwI95L 0mEjXx54mTHgoOtsT0NNAKEAjrHukfS9q+AyCdNF9qx6klaDtZEKWYkdAWM5CTjAwGvHdm+dVPD sfpVcrEhgA4apusS6wmaC+2CKflo= X-Google-Smtp-Source: AGHT+IHcngz3WoF5GTtAUasns5W+8ETq0Jl3yE8Pv37jdR6rv02GTeyIbZUsbmW3zZCw8nOp150WHSQoq9pbqxriYP4= X-Received: by 2002:a05:6512:10d4:b0:513:a8d4:1548 with SMTP id k20-20020a05651210d400b00513a8d41548mr1927494lfg.39.1710141998513; Mon, 11 Mar 2024 00:26:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Mon, 11 Mar 2024 08:26:27 +0100 Message-ID: Subject: Re: [PATCH] [strub] improve handling of indirected volatile parms [PR112938] To: Alexandre Oliva Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.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,WEIRD_QUOTING 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 Sat, Mar 9, 2024 at 10:10=E2=80=AFAM Alexandre Oliva = wrote: > > > The earlier patch for PR112938 arranged for volatile parms to be made > indirect in internal strub wrapped bodies. > > The first problem that remained, more evident, was that the indirected > parameter remained volatile, despite the indirection, but it wasn't > regimplified, so indirecting it was malformed gimple. > > Regimplifying turned out not to be needed. The best course of action > was to drop the volatility from the by-reference parm, that was being > unexpectedly inherited from the original volatile parm. > > That exposed another problem: the dereferences would then lose their > volatile status, so we had to bring volatile back to them. > > Regstrapped on x86_64-linux-gnu. Ok to install? OK > > for gcc/ChangeLog > > PR middle-end/112938 > * ipa-strub.cc (pass_ipa_strub::execute): Drop volatility from > indirected parm. > (maybe_make_indirect): Restore volatility in dereferences. > > for gcc/testsuite/ChangeLog > > PR middle-end/112938 > * g++.dg/strub-internal-pr112938.cc: New. > --- > gcc/ipa-strub.cc | 7 +++++++ > gcc/testsuite/g++.dg/strub-internal-pr112938.cc | 12 ++++++++++++ > 2 files changed, 19 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/strub-internal-pr112938.cc > > diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc > index dff94222351ad..8fa7bdf530023 100644 > --- a/gcc/ipa-strub.cc > +++ b/gcc/ipa-strub.cc > @@ -1940,6 +1940,9 @@ maybe_make_indirect (indirect_parms_t &indirect_par= ms, tree op, int *rec) > TREE_TYPE (TREE_TYPE (op)), > op, > build_int_cst (TREE_TYPE (op), 0)); > + if (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (op))) > + && !TREE_THIS_VOLATILE (ret)) > + TREE_SIDE_EFFECTS (ret) =3D TREE_THIS_VOLATILE (ret) =3D 1; > return ret; > } > } > @@ -2894,6 +2897,10 @@ pass_ipa_strub::execute (function *) > probably drop the TREE_ADDRESSABLE and keep the TRUE. */ > tree ref_type =3D build_ref_type_for (nparm); > > + if (TREE_THIS_VOLATILE (nparm) > + && TYPE_VOLATILE (TREE_TYPE (nparm)) > + && !TYPE_VOLATILE (ref_type)) > + TREE_SIDE_EFFECTS (nparm) =3D TREE_THIS_VOLATILE (nparm) =3D = 0; > DECL_ARG_TYPE (nparm) =3D TREE_TYPE (nparm) =3D ref_type; > relayout_decl (nparm); > TREE_ADDRESSABLE (nparm) =3D 0; > diff --git a/gcc/testsuite/g++.dg/strub-internal-pr112938.cc b/gcc/testsu= ite/g++.dg/strub-internal-pr112938.cc > new file mode 100644 > index 0000000000000..5a74becc2697e > --- /dev/null > +++ b/gcc/testsuite/g++.dg/strub-internal-pr112938.cc > @@ -0,0 +1,12 @@ > +/* { dg-do compile } */ > +/* { dg-options "-fdump-tree-optimized -O2" } */ > +/* { dg-require-effective-target strub } */ > + > +bool __attribute__ ((__strub__ ("internal"))) > +f(bool i, volatile bool j) > +{ > + return (i ^ j) =3D=3D j; > +} > + > +/* Check for two dereferences of the indirected volatile j parm. */ > +/* { dg-final { scan-tree-dump-times {=3D{v} \*j_[0-9][0-9]*(D)} 2 "opti= mized" } } */ > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > More tolerance and less prejudice are key for inclusion and diversity > Excluding neuro-others for not behaving ""normal"" is *not* inclusive