On Tue, 2026-09-15 at 13:14 +0200, Jakub Jelinek wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Tue, Sep 15, 2026 at 10:32:36AM +0000, [email protected] 
> wrote:
> > gcc/ChangeLog:
> > 
> >       * ipa-inline.cc (report_inline_failed_reason): Check for NULL
> >       before calling cl_target_option_print_diff.
> > 
> > diff --git gcc/ipa-inline.cc gcc/ipa-inline.cc
> > index 5a7615666cc..111593f45fd 100644
> > --- gcc/ipa-inline.cc
> > +++ gcc/ipa-inline.cc
> > @@ -294,10 +294,14 @@ report_inline_failed_reason (struct cgraph_edge *e)
> >                          e->callee->ultimate_alias_target 
> > ()->lto_file_data->file_name);
> >       }
> >        if (e->inline_failed == CIF_TARGET_OPTION_MISMATCH)
> > -     if (dump_file)
> > -       cl_target_option_print_diff
> > -         (dump_file, 2, target_opts_for_fn (e->caller->decl),
> > -          target_opts_for_fn (e->callee->ultimate_alias_target ()->decl));
> > +     {
> > +       struct cl_target_option *opt_caller
> > +         = target_opts_for_fn (e->caller->decl);
> > +       struct cl_target_option *opt_callee
> > +         = target_opts_for_fn (e->callee->ultimate_alias_target ()->decl);
> > +       if (dump_file && opt_caller != NULL && opt_callee != NULL)
> > +         cl_target_option_print_diff (dump_file, 2, opt_caller, 
> > opt_callee);
> > +     }
> 
> Isn't it a waste of compile time to call target_opts_for_fn when it actually
> isn't needed in the dump_file == NULL case?
> Wouldn't it be better to
> add && dump_file to the if (e->inline_failed == CIF_TARGET_OPTION_MISMATCH)
> condition and leave it out from the inner one?

Yes, missed that. Fixed in the patch below, looks ok?

Regards
Senthil

gcc/ChangeLog:

        * ipa-inline.cc (report_inline_failed_reason): Check for NULL
        before calling cl_target_option_print_diff.

diff --git gcc/ipa-inline.cc gcc/ipa-inline.cc
index 5a7615666cc..ba8bf11b66e 100644
--- gcc/ipa-inline.cc
+++ gcc/ipa-inline.cc
@@ -293,11 +293,16 @@ report_inline_failed_reason (struct cgraph_edge *e)
                           e->caller->lto_file_data->file_name,
                           e->callee->ultimate_alias_target 
()->lto_file_data->file_name);
        }
-      if (e->inline_failed == CIF_TARGET_OPTION_MISMATCH)
-       if (dump_file)
-         cl_target_option_print_diff
-           (dump_file, 2, target_opts_for_fn (e->caller->decl),
-            target_opts_for_fn (e->callee->ultimate_alias_target ()->decl));
+      if (e->inline_failed == CIF_TARGET_OPTION_MISMATCH
+         && dump_file)
+       {
+         struct cl_target_option *opt_caller
+           = target_opts_for_fn (e->caller->decl);
+         struct cl_target_option *opt_callee
+           = target_opts_for_fn (e->callee->ultimate_alias_target ()->decl);
+         if (opt_caller != NULL && opt_callee != NULL)
+           cl_target_option_print_diff (dump_file, 2, opt_caller, opt_callee);
+       }
       if (e->inline_failed == CIF_OPTIMIZATION_MISMATCH)
        if (dump_file)
          cl_optimization_print_diff

Reply via email to