https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120987

--- Comment #27 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
/* Return true if ECF flags says that stores can be ignored.  */

static bool
ignore_stores_p (tree caller, int flags)
{
  if (flags & (ECF_PURE | ECF_CONST | ECF_NOVOPS))
    return true;
  if ((flags & (ECF_NORETURN | ECF_NOTHROW)) == (ECF_NORETURN | ECF_NOTHROW)
      || (!opt_for_fn (caller, flag_exceptions) && (flags & ECF_NORETURN)))
    return true;
  return false;
}
```

I am trying to understand this. This says if noreturn+nothrow function can
safely ignore the stores which seems reasonible.
And no noreturn with -fno-exceptions can also safely ignore the stores.
But if we inline a nothrow function into a noreturn, then we get
noreturn/nothrow. Which then messes up ignore_stores_p.
Which in this case we have:
gdb_exception::gdb_exception is a nothrow function which is inlined into
throw_exception which is a noreturn function.

This means this loop:
```
  /* Combine in outer flags.  */
  cgraph_node *n;
  for (n = edge->caller; n->inlined_to; n = n->callers->caller)
    flags |= flags_from_decl_or_type (n->decl);
  flags |= flags_from_decl_or_type (n->decl);
```
is wrong.
I am not even sure this loop even makes sense.

Reply via email to