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?

>        if (e->inline_failed == CIF_OPTIMIZATION_MISMATCH)
>       if (dump_file)
>         cl_optimization_print_diff

        Jakub

Reply via email to