From: James Greenhalgh <james.greenhalgh@arm.com>
To: Kyrill Tkachov <kyrylo.tkachov@foss.arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Marcus Shawcroft <marcus.shawcroft@arm.com>,
Richard Earnshaw <Richard.Earnshaw@arm.com>
Subject: Re: [PATCH][AArch64] PR target/70002: Make aarch64_set_current_function play nice with pragma resetting
Date: Thu, 10 Mar 2016 14:51:00 -0000 [thread overview]
Message-ID: <20160310145147.GD38844@arm.com> (raw)
In-Reply-To: <56D82223.8020805@foss.arm.com>
On Thu, Mar 03, 2016 at 11:38:11AM +0000, Kyrill Tkachov wrote:
> Hi all,
>
> This patch fixes the ICE that was introduced by my earlier patch to aarch64_set_current_function:
> FAIL: gcc.dg/torture/pr52429.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (internal compiler error)
>
> And it also fixes a bug that I was working on separately relating to popping pragmas.
> The patch rewrites the aarch64_set_current_function implementation to be the same as the one in the arm port
> that Christian wrote and which is simpler than the existing implementation and has been tested for some time
> without problems. I've thought this was the way to go but was hoping to do it for GCC 7 instead, but I think
> given the ICE we'd rather have consistent implementations of this hook between arm and aarch64 (and ideally
> this should be moved into the midend for all targets, I don't see much target-specific information in the
> implementation of this across the targets, but not at this stage).
>
> Similar to that implementation the setting and restoring of the target globals is factored into a separate
> function that is used in aarch64_set_current_function and the pragma handling function to tell the midend
> when to reinitialise its structures.
>
> This patch fixes the ICE, the testcase attached, and passes bootstrap and regression testing on
> aarch64-none-linux-gnu.
>
> Sorry for missing the ICE originally.
> Ok for trunk?
OK with the typos below fixed.
> diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c
> index 3590ae0daa5d80050b0f81cd6ab9a7779f463516..e057daaec24c0add673d0b2c776d4c4c43d1f0ea 100644
> --- a/gcc/config/aarch64/aarch64-c.c
> +++ b/gcc/config/aarch64/aarch64-c.c
> @@ -178,6 +178,12 @@ aarch64_pragma_target_parse (tree args, tree pop_target)
>
> cpp_opts->warn_unused_macros = saved_warn_unused_macros;
>
> + /* If we're popping or reseting make sure to update the globals so that
> + the optab availability predicates get recomputed. */
> + if (pop_target)
> + aarch64_save_restore_target_globals (pop_target);
> +
> +
Extra newline.
> /* Initialize SIMD builtins if we haven't already.
> Set current_target_pragma to NULL for the duration so that
> the builtin initialization code doesn't try to tag the functions
> diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
> index e4e49fc9ccc3d568c84b35c1a0c0733475017cca..c40d2b0c78494b50508c1b5135b8ee7676a61631 100644
> --- a/gcc/config/aarch64/aarch64-protos.h
> +++ b/gcc/config/aarch64/aarch64-protos.h
> @@ -361,6 +361,7 @@ void aarch64_emit_call_insn (rtx);
> void aarch64_register_pragmas (void);
> void aarch64_relayout_simd_types (void);
> void aarch64_reset_previous_fndecl (void);
> +void aarch64_save_restore_target_globals (tree);
> void aarch64_emit_approx_rsqrt (rtx, rtx);
>
> /* Initialize builtins for SIMD intrinsics. */
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 1e10d9798ddc5f5d2aac4255d3a8fe4ecaf1402a..a05160e08d0474ed9c1e2afa1d00375839417034 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -8570,6 +8570,21 @@ aarch64_reset_previous_fndecl (void)
> aarch64_previous_fndecl = NULL;
> }
>
> +/* Restore or save the TREE_TARGET_GLOBALS from or to NEW_TREE.
> + Used by aarch64_set_current_function and aarch64_pragma_target_parse to
> + make sure optab availability predicates are recomputed when necessary. */
> +
> +void
> +aarch64_save_restore_target_globals (tree new_tree)
> +{
> + if (TREE_TARGET_GLOBALS (new_tree))
> + restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
> + else if (new_tree == target_option_default_node)
> + restore_target_globals (&default_target_globals);
> + else
> + TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
> +}
> +
> /* Implement TARGET_SET_CURRENT_FUNCTION. Unpack the codegen decisions
> like tuning and ISA features from the DECL_FUNCTION_SPECIFIC_TARGET
> of the function, if such exists. This function may be called multiple
> @@ -8579,63 +8594,32 @@ aarch64_reset_previous_fndecl (void)
> static void
> aarch64_set_current_function (tree fndecl)
> {
> + if (!fndecl || fndecl == aarch64_previous_fndecl)
> + return;
> +
> tree old_tree = (aarch64_previous_fndecl
> ? DECL_FUNCTION_SPECIFIC_TARGET (aarch64_previous_fndecl)
> : NULL_TREE);
>
> - tree new_tree = (fndecl
> - ? DECL_FUNCTION_SPECIFIC_TARGET (fndecl)
> - : NULL_TREE);
> -
> + tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
>
> - if (fndecl && fndecl != aarch64_previous_fndecl)
> - {
> - aarch64_previous_fndecl = fndecl;
> - if (old_tree == new_tree)
> - ;
> + /* If current function has no attributes but previous one did,
s/but previous/but the previous/
> + use the default node. */
> + if (!new_tree && old_tree)
> + new_tree = target_option_default_node;
>
> - else if (new_tree)
> - {
> - cl_target_option_restore (&global_options,
> - TREE_TARGET_OPTION (new_tree));
> - if (TREE_TARGET_GLOBALS (new_tree))
> - restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
> - else
> - TREE_TARGET_GLOBALS (new_tree)
> - = save_target_globals_default_opts ();
> - }
> + /* If nothing to do return. #pragma GCC reset or #pragma GCC pop to
s/to do return/to do, return/
Thanks,
James
next prev parent reply other threads:[~2016-03-10 14:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 11:38 Kyrill Tkachov
2016-03-10 12:24 ` Kyrill Tkachov
2016-03-10 14:51 ` James Greenhalgh [this message]
2016-03-11 15:27 ` Kyrill Tkachov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160310145147.GD38844@arm.com \
--to=james.greenhalgh@arm.com \
--cc=Richard.Earnshaw@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kyrylo.tkachov@foss.arm.com \
--cc=marcus.shawcroft@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).