This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix libgo breakage (PR tree-optimization/67284)
- From: Marek Polacek <polacek at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 21 Aug 2015 18:42:15 +0200
- Subject: Re: [PATCH] Fix libgo breakage (PR tree-optimization/67284)
- Authentication-results: sourceware.org; auth=none
- References: <20150821105233 dot GJ2729 at redhat dot com> <CAFiYyc1F8Vr9DfPuVwhYje9S0DQ1fUxmeSROkUo8u_4_u1q04g at mail dot gmail dot com> <20150821124922 dot GK2729 at redhat dot com> <CAFiYyc0zUPg=xUGxMka-JY36UqXYEk=aWarnrWvHPL4y=PKe-w at mail dot gmail dot com> <20150821144122 dot GL2729 at redhat dot com> <55D73F3A dot 5080901 at redhat dot com> <E2BA4AB5-D96D-4218-AAB7-9B26755679E7 at suse dot de>
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).
This is a patch to also generate __builtin_unreachable, just for the record.
Bootstrapped/regtested on x86_64-linux.
2015-08-21 Marek Polacek <polacek@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