aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-10-03 15:21:05 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-10-04 17:07:29 +0200
commitc4ee0965371c9b243cca1305b443f54c5e4e236a (patch)
treea9863e54fa1c81659543c3f88e442aaa48ef026d
parent7e0c0500808d58bca5b8e23cbd474022c32234e4 (diff)
downloadgcc-c4ee0965371c9b243cca1305b443f54c5e4e236a.zip
gcc-c4ee0965371c9b243cca1305b443f54c5e4e236a.tar.gz
gcc-c4ee0965371c9b243cca1305b443f54c5e4e236a.tar.bz2
d: Save target node before parsing optimize options in case it changes.
Fixes an ICE seen on PowerPC targets with the attr_optimize*.d tests in the gdc.dg testsuite. gcc/d/ChangeLog: * d-attribs.cc (d_handle_optimize_attribute): Save target node before calling parse_optimize_options in case it changes.
-rw-r--r--gcc/d/d-attribs.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index 0708660..d81b7d1 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -896,6 +896,8 @@ d_handle_optimize_attribute (tree *node, tree name, tree args, int,
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options, &global_options_set);
+ tree prev_target_node = build_target_option_node (&global_options,
+ &global_options_set);
/* If we previously had some optimization options, use them as the
default. */
@@ -914,10 +916,16 @@ d_handle_optimize_attribute (tree *node, tree name, tree args, int,
parse_optimize_options (args);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node (&global_options, &global_options_set);
+ tree target_node = build_target_option_node (&global_options,
+ &global_options_set);
+ if (prev_target_node != target_node)
+ DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node;
/* Restore current options. */
cl_optimization_restore (&global_options, &global_options_set,
&cur_opts);
+ cl_target_option_restore (&global_options, &global_options_set,
+ TREE_TARGET_OPTION (prev_target_node));
if (saved_global_options != NULL)
{
cl_optimization_compare (saved_global_options, &global_options);