On Mon, Jan 29, 2024 at 2:11 AM Jakub Jelinek <ja...@redhat.com> wrote: > > On Sat, Jan 27, 2024 at 07:00:03AM -0800, H.J. Lu wrote: > > On Sat, Jan 27, 2024 at 6:09 AM Jakub Jelinek <ja...@redhat.com> wrote: > > > > > > On Sat, Jan 27, 2024 at 05:52:34AM -0800, H.J. Lu wrote: > > > > @@ -3391,7 +3392,9 @@ ix86_set_func_type (tree fndecl) > > > > function is marked as noreturn in the IR output, which leads the > > > > incompatible attribute error in LTO1. */ > > > > bool has_no_callee_saved_registers > > > > - = (((TREE_NOTHROW (fndecl) || !flag_exceptions) > > > > + = ((optimize > > > > + && !optimize_debug > > > > > > Shouldn't that be opt_for_fn (fndecl, optimize) and ditto for > > > optimize_debug? > > > I mean, aren't the options not restored yet when this function is called > > > (i.e. remain in whatever state they were in the previous function or > > > global state)? > > > > store_parm_decls is called when parsing a function. store_parm_decls > > calls allocate_struct_function which calls > > > > invoke_set_current_function_hook (fndecl); > > > > which has > > > > /* Change optimization options if needed. */ > > if (optimization_current_node != opts) > > { > > optimization_current_node = opts; > > cl_optimization_restore (&global_options, &global_options_set, > > TREE_OPTIMIZATION (opts)); > > } > > > > targetm.set_current_function (fndecl); > > > > which calls ix86_set_current_function after global_options > > has been updated. ix86_set_func_type is called from > > ix86_set_current_function. > > Sorry, you're right, I just saw option restore later in > ix86_set_current_function > and missed that it is target option restore only. > > > > Also, why check "noreturn" attribute rather than > > > TREE_THIS_VOLATILE (fndecl)? > > > > > > > The comments above this code has > > > > NB: Don't use TREE_THIS_VOLATILE to check if this is a noreturn > > function. The local-pure-const pass turns an interrupt function > > into a noreturn function by setting TREE_THIS_VOLATILE. Normally > > the local-pure-const pass is run after ix86_set_func_type is called. > > When the local-pure-const pass is enabled for LTO, the interrupt > > function is marked as noreturn in the IR output, which leads the > > incompatible attribute error in LTO1. > > So in that case, I think it would be best to test > TREE_THIS_VOLATILE (fndecl) > && lookup_attribute ("noreturn", DECL_ATTRIBUTES (fndecl)) > && ... > because if it doesn't have noreturn attribute, it will not have > TREE_THIS_VOLATILE set and TREE_THIS_VOLATILE is much cheaper to test than > looking an attribute. >
Fixed in the v3 patch: https://patchwork.sourceware.org/project/gcc/list/?series=30308 Thanks. -- H.J.