From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50EB93858414; Thu, 2 Dec 2021 01:43:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50EB93858414 From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103515] Unexpected OPTION_MASK_SAVE_TOC_INDIRECT of rs6000_isa_flag Date: Thu, 02 Dec 2021 01:43:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 01:43:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103515 --- Comment #2 from Kewen Lin --- Here I assumed that the current cl optimization/option save and restore sch= eme wants to keep the global_option/global_option_set same as the one from the initial option processing. After we parsing all attributes/pragmas, we can expect the rs6000_isa_flags back to the default one. The fix seems to require us to take this OPTION_MASK_SAVE_TOC_INDIRECT as o= ne option which would be affected by optimize level. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 327822e5357..f9ee7044889 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3478,6 +3478,16 @@ rs6000_override_options_after_change (void) } else if (!OPTION_SET_P (flag_cunroll_grow_size)) flag_cunroll_grow_size =3D flag_peel_loops || optimize >=3D 3; + /* If we can shrink-wrap the TOC register save separately, then use + -msave-toc-indirect unless explicitly disabled. */ + if ((rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT) =3D=3D 0 + && flag_shrink_wrap_separate + && optimize_function_for_speed_p (cfun)) + rs6000_isa_flags |=3D OPTION_MASK_SAVE_TOC_INDIRECT; + else + rs6000_isa_flags &=3D ~OPTION_MASK_SAVE_TOC_INDIRECT; Also require us to build one target_node when we are going to save one new optimization_node which isn't the same as the default one, since at that ti= me the optimization level changes and the option is possible to be changed as well. diff --git a/gcc/attribs.c b/gcc/attribs.c index c252f5af07b..3382c095fa8 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -607,7 +607,14 @@ decl_attributes (tree *node, tree attributes, int flag= s, if (TREE_CODE (*node) =3D=3D FUNCTION_DECL && optimization_current_node !=3D optimization_default_node && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)) - DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) =3D optimization_current_n= ode; + { + DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) =3D optimization_current= _node; + tree target_node + =3D build_target_option_node (&global_options, &global_options_set= ); + if (!DECL_FUNCTION_SPECIFIC_TARGET (*node) + && target_node !=3D target_option_default_node) + DECL_FUNCTION_SPECIFIC_TARGET (*node) =3D target_node; + } /* If this is a function and the user used #pragma GCC target, add the options to the attribute((target(...))) list. */=