On August 21, 2015 6:42:15 PM GMT+02:00, Marek Polacek <pola...@redhat.com> 
wrote:
>On Fri, Aug 21, 2015 at 06:23:09PM +0200, Richard Biener wrote:
>> >> Yes, but gimple_call_noreturn_p is false on __builtin_trap. 
>That's
>> >quite
>> >> confusing... but flags_from_decl_or_type really returns 0 for
>> >__builtin_trap.
>> >Well, if that's intentional (and offhand I have no idea if it is),
>then
>> >
>> >you could emit a __builtin_trap followed by a __builtin_unreachable.
>> 
>> But maybe go is non-call-exceptions  and that makes a difference?
>
>I suppose that's the case.  In Makefile.am I see
>AM_CFLAGS = -fexceptions -fnon-call-exceptions -fplan9-extensions
>But I'm not clear on how this could make a difference wrt whether
>__builtin_trap is volatile (thus ECF_NORETURN).

Not sure either. Needs to be investigated. BTW, built-in trap is also nothrow 
AFAIR.

Richard.

>This is a patch to also generate __builtin_unreachable, just for the
>record.
>
>Bootstrapped/regtested on x86_64-linux.
>
>2015-08-21  Marek Polacek  <pola...@redhat.com>
>
>       PR tree-optimization/67284
>       * gimple-ssa-isolate-paths.c (insert_trap): Also emit
>       __builtin_unreachable.
>
>diff --git gcc/gimple-ssa-isolate-paths.c
>gcc/gimple-ssa-isolate-paths.c
>index ca2322d..06263d3 100644
>--- gcc/gimple-ssa-isolate-paths.c
>+++ gcc/gimple-ssa-isolate-paths.c
>@@ -97,15 +97,18 @@ insert_trap (gimple_stmt_iterator *si_p, tree op)
>     = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
>   gimple_seq seq = NULL;
>   gimple_seq_add_stmt (&seq, new_stmt);
>+  new_stmt
>+     = gimple_build_call (builtin_decl_explicit
>(BUILT_IN_UNREACHABLE), 0);
>+  gimple_seq_add_stmt (&seq, new_stmt);
> 
>   /* If we had a NULL pointer dereference, then we want to insert the
>-     __builtin_trap after the statement, for the other cases we want
>-     to insert before the statement.  */
>+     __builtin_trap/__builtin_unreachable pair after the statement,
>for
>+     the other cases we want to insert before the statement.  */
>   if (walk_stmt_load_store_ops (stmt, (void *)op,
>                               check_loadstore,
>                               check_loadstore))
>     {
>-      gsi_insert_after (si_p, seq, GSI_NEW_STMT);
>+      gsi_insert_seq_after (si_p, seq, GSI_NEW_STMT);
>       if (stmt_ends_bb_p (stmt))
>       {
>         split_block (gimple_bb (stmt), stmt);
>@@ -113,7 +116,7 @@ insert_trap (gimple_stmt_iterator *si_p, tree op)
>       }
>     }
>   else
>-    gsi_insert_before (si_p, seq, GSI_NEW_STMT);
>+    gsi_insert_seq_before (si_p, seq, GSI_NEW_STMT);
> 
>   split_block (gimple_bb (new_stmt), new_stmt);
>   *si_p = gsi_for_stmt (stmt);
>@@ -194,7 +197,7 @@ isolate_path (basic_block bb, basic_block
>duplicate,
> 
>/* If we did not run to the end of DUPLICATE, then SI points to STMT
>and
>      SI2 points to the duplicate of STMT in DUPLICATE.  Insert a trap
>-     before SI2 and remove SI2 and all trailing statements.  */
>+     before SI2 and split the block.  */
>   if (!gsi_end_p (si2))
>     {
>       if (ret_zero)
>
>       Marek


Reply via email to