From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 08BD2385842A; Mon, 11 Dec 2023 19:33:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08BD2385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702323187; bh=iAY6dsIJz2gajcRDhRwFfzCqz871kZKdMnJSHLyrY0U=; h=From:To:Subject:Date:From; b=d1lMpOICtGYv9sN3FKhqYT+vjBYc+YvkxImg5ReHl5YFfMiRrkjZoT/VdJkcTjQNG yKOUz4I3hfMcz9w6VaHfeOwxpuLLlnELLuB/hXKgxE31g54V9qr8rLIutxryxTA6gG 0l4R5ggXRA5GRZZiGHLvsNzP+lPtJhdi6YjT/hi0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] strub: drop volatile from wrapper args X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: ee1d376e6d2d6f45a59e6f9319423fbc397899e2 X-Git-Newrev: 7fd452fd7d93f55bb982aed09ccc4a7d26fd57d5 Message-Id: <20231211193307.08BD2385842A@sourceware.org> Date: Mon, 11 Dec 2023 19:33:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7fd452fd7d93f55bb982aed09ccc4a7d26fd57d5 commit 7fd452fd7d93f55bb982aed09ccc4a7d26fd57d5 Author: Alexandre Oliva Date: Mon Dec 11 16:16:45 2023 -0300 strub: drop volatile from wrapper args Diff: --- gcc/ipa-strub.cc | 14 +++++++++++--- gcc/testsuite/c-c++-common/strub-internal-volatile.c | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc index 45294b0b46b..bab20c386bb 100644 --- a/gcc/ipa-strub.cc +++ b/gcc/ipa-strub.cc @@ -2922,6 +2922,16 @@ pass_ipa_strub::execute (function *) if (nparmt) adjust_ftype++; } + else if (TREE_THIS_VOLATILE (parm)) + { + /* Drop volatile from wrapper's arguments, they're just + temporaries copied to the wrapped function. ??? Should + we drop TYPE_QUAL_ATOMIC as well? */ + TREE_TYPE (parm) = build_qualified_type (TREE_TYPE (parm), + TYPE_QUALS (TREE_TYPE (parm)) + & ~TYPE_QUAL_VOLATILE); + TREE_THIS_VOLATILE (parm) = 0; + } /* Also adjust the wrapped function type, if needed. */ if (adjust_ftype) @@ -3224,9 +3234,7 @@ pass_ipa_strub::execute (function *) { tree tmp = arg; /* If ARG is e.g. volatile, we must copy and - convert in separate statements. ??? Should - we drop volatile from the wrapper - instead? */ + convert in separate statements. */ if (!is_gimple_val (arg)) { tmp = create_tmp_reg (TYPE_MAIN_VARIANT diff --git a/gcc/testsuite/c-c++-common/strub-internal-volatile.c b/gcc/testsuite/c-c++-common/strub-internal-volatile.c index cdfca67616b..4eb62ee40d5 100644 --- a/gcc/testsuite/c-c++-common/strub-internal-volatile.c +++ b/gcc/testsuite/c-c++-common/strub-internal-volatile.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-options "-fdump-ipa-strub" } */ /* { dg-require-effective-target strub } */ void __attribute__ ((strub("internal"))) @@ -8,3 +9,7 @@ f(volatile short) { void g(void) { f(0); } + +/* We drop volatile from the wrapper, and keep it in the wrapped f, so + the count remains 1. */ +/* { dg-final { scan-tree-dump "volatile" 1 "strub" } } */