On Tue, May 13, 2025 at 10:42 PM Andrew Pinski <quic_apin...@quicinc.com> wrote: > > This is the followup mentioned in > https://gcc.gnu.org/pipermail/gcc-patches/2025-May/683444.html . > It adds the check for cfun before accessing function specific flags. > We handle the case where !cfun as conservative in that it the function might > throw.
OK. > gcc/ChangeLog: > > * gimple-fold.cc (replace_stmt_with_simplification): Check cfun before > accessing cfun. > > Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com> > --- > gcc/gimple-fold.cc | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > index 28c5069931d..b74fb8bb50c 100644 > --- a/gcc/gimple-fold.cc > +++ b/gcc/gimple-fold.cc > @@ -6081,8 +6081,9 @@ replace_stmt_with_simplification (gimple_stmt_iterator > *gsi, > auto code = tree_code (res_op->code); > if (TREE_CODE_CLASS (code) == tcc_comparison > /* GIMPLE_CONDs condition may not throw. */ > - && (!flag_exceptions > - || !cfun->can_throw_non_call_exceptions > + && ((cfun > + && (!flag_exceptions > + || !cfun->can_throw_non_call_exceptions)) > || !operation_could_trap_p (code, > FLOAT_TYPE_P (TREE_TYPE (ops[0])), > false, NULL_TREE))) > @@ -6124,8 +6125,9 @@ replace_stmt_with_simplification (gimple_stmt_iterator > *gsi, > `(ne (cmp @0 @1) integer_zerop)` which creates a new expression > for the comparison. */ > if (TREE_CODE_CLASS (code) == tcc_comparison > - && flag_exceptions > - && cfun->can_throw_non_call_exceptions > + && (!cfun > + || (flag_exceptions > + && cfun->can_throw_non_call_exceptions)) > && operation_could_trap_p (code, > FLOAT_TYPE_P (TREE_TYPE (ops[0])), > false, NULL_TREE)) > -- > 2.43.0 >