From patchwork Tue Dec 12 02:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1874840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=FfyaIn/a; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sq22d1rGNz20Gd for ; Tue, 12 Dec 2023 13:03:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0DA843858418 for ; Tue, 12 Dec 2023 02:03:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 07C843858C5F for ; Tue, 12 Dec 2023 02:03:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07C843858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 07C843858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702346587; cv=none; b=GplnIsWxxB9OEBU/O5XG1rcUAIvZQftR/Eo4MZaMCtsbyeaLDqnajYirr4OjrGf93RvGK2xOcwMQeUsa9gsvtedY23AtNK7uLfZqoAbKgUUd993tKUJE8FfKP17AHJHs5Oai4fz7PEDa0IRZNMcW4I7DPUJduxnIQzjt/jnXpKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702346587; c=relaxed/simple; bh=IjPr4/r+rFFJfee9ggnB5mkdhvMzC2WAzs0gbjfuDCI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=P2wJjfcz5ZAXNrqd6Ih26d/ZkRIufTGEGWYoer2WYKUzTRVm6u8jpgyrmlHsTv/ql27wJO03Chm+3bY+7uI8QyjCEg6uSsufoFOaqcu7XRkKACbh63QumTIendLzJZygJgaLWpugnnoMQJt3aE8W2fZPi+cCFB/hPU53EI4H4qA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3b9f111c114so2067726b6e.1 for ; Mon, 11 Dec 2023 18:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702346584; x=1702951384; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/iPqVMLxRLgznp1Rbg6k/WMCWSv1S900lI6xahSR0eA=; b=FfyaIn/aLTwxUThM/Ok12hZQA0XvIhrXtkkLye72ohNEg8YxeXE1ZSfksFHHqXWUyf fr+bpSNb/mSsz2e7/fO4tVq/dQ49x8U8Nx4CoqVUyCLe+6QZ+Jfsmitzb5dXYBuSwfRh RKxOnT2adkLs2QA3N1+T6zmiuXqriVBUFQLb/d2cXtnuEV6F3zqZwLFvmkNZUVsdEpiy Nph+SaE/x9HyluciOkC4ica2e1t5LEVrVLPsrcfzJHrbXF3vl7gtXvGpquHUuxkTGnUF lepxU528W2mmELyJhVJoU6aHkJQiIyok4Qg5eFylzX0yrfAPEQ6NYYRtwoTtWM348MEo RvbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702346584; x=1702951384; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/iPqVMLxRLgznp1Rbg6k/WMCWSv1S900lI6xahSR0eA=; b=Cqy2/jKI91lwJ+/83O4mJCAb9LbCbH+AmUgQlcNp2Ffh0uUaHQq9JcvH+hDa/tcekN c161EJybQLiBpsNFMKaWfEPtq+WwJiGDYmvyaPeESjemsTF0NAk9CkYAT3ovw5H4jxH4 GGi+A9fTzhKigyis0wmoKeSaNCcOz0dH6tfl405Q/pTCwlKBywlBfXWNE2FeY3zb2xPH LhPUsK94hmAv99FcO935ZJcLC82NXReE7XeTuSVO5CQQQ0FxEtmVAQqSImDdAVoSa8bO XTle89IT1BZIk2XVY08qOHci5kHPFIeU29F9501oTZ9gmH5Q1jDr+QG5oMBUAJujxi62 4+aw== X-Gm-Message-State: AOJu0YwYIuKkdUl9Vq+GMRHJaQlS23SfpiX/CUHGksCw/Vm/dzkYcemO UNbs0XPeXDNmlKU33vAwLDw9XtPtdX11dEb9wxwhrw== X-Google-Smtp-Source: AGHT+IEl9Pdi9e4//ke1Nxcfb8N6/Ea9ZY4zY/+8omzjuqAeSUmuMLFQYnl7QwA/Q2lm7NkZC9Eaqw== X-Received: by 2002:a05:6808:21a9:b0:3b9:e118:e423 with SMTP id be41-20020a05680821a900b003b9e118e423mr5937515oib.32.1702346583749; Mon, 11 Dec 2023 18:03:03 -0800 (PST) Received: from free.home ([2804:14c:4d1:44a5:f4d9:b7a4:4fb8:376f]) by smtp.gmail.com with ESMTPSA id je11-20020a170903264b00b001cffe1e7374sm7381166plb.214.2023.12.11.18.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:03:03 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3BC22o2m397404 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 23:02:51 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PATCH #1/2] strub: handle volatile promoted args in internal strub [PR112938] Organization: Free thinker, does not speak for AdaCore Date: Mon, 11 Dec 2023 23:02:50 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When generating code for an internal strub wrapper, don't clear the DECL_NOT_GIMPLE_REG_P flag of volatile args, and gimplify them both before and after any conversion. While at that, move variable TMP into narrower scopes so that it's more trivial to track where ARG lives. Regstrapped on x86_64-linux-gnu. Ok to install? (there's a #2/2 followup coming up that addresses the ??? comment added herein) for gcc/ChangeLog PR middle-end/112938 * ipa-strub.cc (pass_ipa_strub::execute): Handle promoted volatile args in internal strub. Simplify. for gcc/testsuite/ChangeLog PR middle-end/112938 * gcc.dg/strub-internal-volatile.c: New. --- gcc/ipa-strub.cc | 29 +++++++++++++++++------- gcc/testsuite/gcc.dg/strub-internal-volatile.c | 10 ++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/strub-internal-volatile.c diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc index 8ec6824e8a802..45294b0b46bcb 100644 --- a/gcc/ipa-strub.cc +++ b/gcc/ipa-strub.cc @@ -3203,7 +3203,6 @@ pass_ipa_strub::execute (function *) i++, arg = DECL_CHAIN (arg), nparm = DECL_CHAIN (nparm)) { tree save_arg = arg; - tree tmp = arg; /* Arrange to pass indirectly the parms, if we decided to do so, and revert its type in the wrapper. */ @@ -3211,10 +3210,9 @@ pass_ipa_strub::execute (function *) { tree ref_type = TREE_TYPE (nparm); TREE_ADDRESSABLE (arg) = true; - tree addr = build1 (ADDR_EXPR, ref_type, arg); - tmp = arg = addr; + arg = build1 (ADDR_EXPR, ref_type, arg); } - else + else if (!TREE_THIS_VOLATILE (arg)) DECL_NOT_GIMPLE_REG_P (arg) = 0; /* Convert the argument back to the type used by the calling @@ -3223,16 +3221,31 @@ pass_ipa_strub::execute (function *) double to be passed on unchanged to the wrapped function. */ if (TREE_TYPE (nparm) != DECL_ARG_TYPE (nparm)) - arg = fold_convert (DECL_ARG_TYPE (nparm), arg); + { + 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? */ + if (!is_gimple_val (arg)) + { + tmp = create_tmp_reg (TYPE_MAIN_VARIANT + (TREE_TYPE (arg)), "arg"); + gimple *stmt = gimple_build_assign (tmp, arg); + gsi_insert_after (&bsi, stmt, GSI_NEW_STMT); + } + arg = fold_convert (DECL_ARG_TYPE (nparm), tmp); + } if (!is_gimple_val (arg)) { - tmp = create_tmp_reg (TYPE_MAIN_VARIANT - (TREE_TYPE (arg)), "arg"); + tree tmp = create_tmp_reg (TYPE_MAIN_VARIANT + (TREE_TYPE (arg)), "arg"); gimple *stmt = gimple_build_assign (tmp, arg); gsi_insert_after (&bsi, stmt, GSI_NEW_STMT); + arg = tmp; } - vargs.quick_push (tmp); + vargs.quick_push (arg); arg = save_arg; } /* These strub arguments are adjusted later. */ diff --git a/gcc/testsuite/gcc.dg/strub-internal-volatile.c b/gcc/testsuite/gcc.dg/strub-internal-volatile.c new file mode 100644 index 0000000000000..cdfca67616bc8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/strub-internal-volatile.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target strub } */ + +void __attribute__ ((strub("internal"))) +f(volatile short) { +} + +void g(void) { + f(0); +} From patchwork Tue Dec 12 02:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1874859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=UfhBlZcQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sq3324yQwz1ySd for ; Tue, 12 Dec 2023 13:48:46 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C3873857BA2 for ; Tue, 12 Dec 2023 02:48:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id E27423858C54 for ; Tue, 12 Dec 2023 02:48:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E27423858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E27423858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702349313; cv=none; b=rZQX0KOvp7m7+EpS53dQ1fclG2XB6ioj+FAgs0ovaCJsxI7dvEDcX6/9UZBCgLvxOJWYzWP10oqdHpkAlyQPy5gtwgD4ToedJMRkUW2PGDfvCs7LlCXBFGcGN+6qVGcLftsMg3jUYIPexbAX8xQaMOJmXacvVLgpJVXBUg9mzow= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702349313; c=relaxed/simple; bh=bjPkjexsYB9lLmb+vjPlrjMhAZ2cYVJkMgz9JUy5jKA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PLCosY8JaMPVEJOwKlt3YpWKWTiO0el01bJs2YaMDo4DvLB1b8wdcWpMZqZW20Ev5yb8Qk+PzF24cgxygy4bwfACZ8j0EbFrqYzc2NQ2LMaYSI1mnKNLQs0WDLKNiVB5hQ73kXw5r0tr4a+XdruGM0GxWN++hsXEWhGGQDMk3R0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6d9e756cf32so3140695a34.2 for ; Mon, 11 Dec 2023 18:48:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702349307; x=1702954107; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SxeCrt9CBhuaFXUJq6rJv4RdV5UDc6T8V8S8EG56w/E=; b=UfhBlZcQm2+i2jfOaaBZufhIW4Q2+PIi+ste8G2TV9NF9RgS2d/yn10JBGvDHziIQ8 FxWjaHCpTcTMpuCUbGFiCN8EZgwyj20aVSSsfJBAqvfsMOgWlZlomHPD+ZOpMY9C6Ql2 B4b1gEk8yITkuiD45+NidF7uQbpuraRDq/9NdULJzn/ASI/5LwrBa+0vua5pdzCOwOgR HF0U6viC42085BKMAEljAyw2Ql7D/Nrdgq9uBh+PCJJ61JmLvm+fidbJ2eX0Ub+ZBAwM IebNjU4hqBfiOlYf8vZpr4PumCO9ODAC69qklMdSfRSoD7YIFcC6sQoLtAhLSR9Q46+X liqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702349307; x=1702954107; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:to:from:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=SxeCrt9CBhuaFXUJq6rJv4RdV5UDc6T8V8S8EG56w/E=; b=tB/ENfP8Ddf5sd2JQ/Er/2dOJfFZkjT0y4fr2UQDh54Cba0bN05oqTf5PqPTvHI0iV SBKKVQItgCzbtvr6fYJaU/0+ZtaZkQGrrGYE067e8fTgdRWtjxPXVMeZiQfkTA/LkYlM nXDP77MQuX/MbMN4cwlMgNbUMqyGBgBd4PdbXXkcXyEb6/zC6CB0xKRXoMi44pAt876R obzhWHj7TuGSxdbFGypKRgqSjNMyGUwR/ee/dA+it8qBgiGFQEqjjtyj8LW6IHwjjyaw j9YqJ6b5y2wXsXbRoCp/PaVyDcKUpVsm1SSNiFT9sXztFk+PVlc8xeIPsqLHgOLzASRb JuRQ== X-Gm-Message-State: AOJu0Yx6R2VKeAA04+YEzsGAWtfgQv85sr0wcW0qCdp++bTXe37O/91g PaLCDc0u3Fi60d3igWoZ19tCWY4QVWhZQAWKJsduCQ== X-Google-Smtp-Source: AGHT+IEPmraMvaLcdaHfZUD+GWM7a5FFNd3UpIEXnZABPQmpnpsoehBl34uzU7Vbt2/yLWhHMjTlkA== X-Received: by 2002:a05:6359:71c1:b0:170:17eb:3790 with SMTP id uf1-20020a05635971c100b0017017eb3790mr5934682rwb.56.1702349306848; Mon, 11 Dec 2023 18:48:26 -0800 (PST) Received: from free.home ([2804:14c:4d1:44a5:f4d9:b7a4:4fb8:376f]) by smtp.gmail.com with ESMTPSA id q4-20020a17090a750400b0028ac07bb4e9sm188612pjk.28.2023.12.11.18.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:48:26 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3BC2mGZ8398385 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 23:48:17 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PATCH #2/2] strub: drop volatile from wrapper args [PR112938] Organization: Free thinker, does not speak for AdaCore References: Date: Mon, 11 Dec 2023 23:48:16 -0300 In-Reply-To: (Alexandre Oliva's message of "Mon, 11 Dec 2023 23:02:50 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org On Dec 11, 2023, Alexandre Oliva wrote: > (there's a #2/2 followup coming up that addresses the ??? comment added > herein) Here it is. Also regstrapped on x86_64-linux-gnu, along with the previous patch (that had also been regstrapped by itself). I think this would be a desirable thing to do (maybe also with TYPE_QUAL_ATOMIC), but I'm a little worried about modifying the types of args of the original function decl, the one that is about to become a wrapper. This would be visible at least in debug information. OTOH, keeping the volatile in the wrapper would serve no useful purpose whatsoever, it would likely just make it slower, and such top-level qualifiers really only apply within the function body, which the wrapper isn't. Thoughts? Ok to install? Drop volatile from argument types in internal strub wrappers that are not made indirect. Their volatility is only relevant within the body of the function, and that body is moved to the wrapped function. for gcc/ChangeLog PR middle-end/112938 * ipa-strub.cc (pass_ipa_strub::execute): Drop volatile from internal strub wrapper args. for gcc/testsuite/ChangeLog PR middle-end/112938 * gcc.dg/strub-internal-volatile.c: Check for dropped volatile in wrapper. --- gcc/ipa-strub.cc | 14 +++++++++++--- gcc/testsuite/gcc.dg/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 45294b0b46bcb..bab20c386bb01 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/gcc.dg/strub-internal-volatile.c b/gcc/testsuite/gcc.dg/strub-internal-volatile.c index cdfca67616bc8..0ffa98d799d32 100644 --- a/gcc/testsuite/gcc.dg/strub-internal-volatile.c +++ b/gcc/testsuite/gcc.dg/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-ipa-dump-times "volatile" 1 "strub" } } */