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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-11-12
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
As Andrew says the reason is that C library builtins are marked nothrow which
currently implies "notrap" in the context of -fnon-call-exceptions.  There's
no separate attribute for not trapping (or IPA discovery of this) but a
simple enough workaround only pessimizing -fnon-call-exceptions would be sth
like the following

diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index c3314bbd78c..bcf6a7fb348 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -2902,6 +2902,12 @@ stmt_could_throw_p (function *fun, gimple *stmt)
       return true;

     case GIMPLE_CALL:
+      /* ???  We need to check whether the callee can throw non-call
+        exceptions or conservatively assume so if we cannot tell but
+        non-call exceptions are enabled.  */
+      if (fun && fun->can_throw_non_call_exceptions
+         || flag_non_call_exceptions)
+       return true;
       return !gimple_call_nothrow_p (as_a <gcall *> (stmt));

     case GIMPLE_COND:

as the comments says the check isn't correct but it might work for simple
non-LTO cases.  Anybody willing to try?

Reply via email to