From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id AFE76385842F; Mon, 11 Dec 2023 18:52:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFE76385842F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702320752; bh=LNHyXMEMOSkNQnY7gF7FmYBoqUQHy7yoqOpnTTE0ORo=; h=From:To:Subject:Date:From; b=ayocigSEyOYvpLhq8V7opuHuZDwgkgJr3I1fJgt65INF9+RjEPjl1SASgz6UXyw+t MQYJ0WAQle2d9wIADJAVfP3W6SxWGJCYGEWyCf59fMOMAsHcvMzMVNaDVQ1/BOZzmU pKxVZPZf6xPpR1c31/I5ya35zN6u99aAXZw8fIYE= 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: handle volatile promoted args in internal strub X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: a8a3d832e609501002dee54150abfd96a28fe532 X-Git-Newrev: db334a69cff94ffc58028b4cd6a4113b2993fd3b Message-Id: <20231211185232.AFE76385842F@sourceware.org> Date: Mon, 11 Dec 2023 18:52:32 +0000 (GMT) List-Id: https://gcc.gnu.org/g:db334a69cff94ffc58028b4cd6a4113b2993fd3b commit db334a69cff94ffc58028b4cd6a4113b2993fd3b Author: Alexandre Oliva Date: Mon Dec 11 15:17:03 2023 -0300 strub: handle volatile promoted args in internal strub Diff: --- gcc/ipa-strub.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc index 8ec6824e8a8..45294b0b46b 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. */