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. I don't see an issue with optimize and optimize_debug here. > Also, shouldn't the lookup_attribute ("noreturn" check be the first one? > I mean, noreturn functions are quite rare and so checking all the other I will fix it and updated one testcase with __attribute__((noreturn, optimize("-Og"))) > conditions upon each set_cfun could waste too much compile time. > > 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. Thanks. -- H.J.