Hi, This patch saves target node information before calling parse_optimize_options in the D "optimize" attribute handler, the same as is done for C/C++ optimize.
Fixes an ICE seen on PowerPC targets with the attr_optimize*.d tests in the gdc.dg testsuite. Bootstrapped and regression tested, and committed to mainline. Regards Iain. --- gcc/d/ChangeLog: * d-attribs.cc (d_handle_optimize_attribute): Save target node before calling parse_optimize_options in case it changes. --- gcc/d/d-attribs.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc index 070866020a2..d81b7d122f7 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); -- 2.30.2