From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109922 invoked by alias); 27 Jun 2019 09:36:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 109906 invoked by uid 89); 27 Jun 2019 09:36:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=que, him, america X-HELO: mail-lf1-f65.google.com Received: from mail-lf1-f65.google.com (HELO mail-lf1-f65.google.com) (209.85.167.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Jun 2019 09:36:34 +0000 Received: by mail-lf1-f65.google.com with SMTP id p24so1102217lfo.6 for ; Thu, 27 Jun 2019 02:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vqYU6IJXp8zfplgpZ2k46P5t7hqDrpgbU8ORIITJEvM=; b=vLqf+8ZKhBNdFYI5VfV89CDxKb+uwl0b2l25ZQu/OZ7jVheVLx8j/+2kLBtvJCN2kP s1lfLlW9sJwHCUu8cIsFLhWcotkej80JjMADsIKdhOoNBrAlzF1U4UfLv6cuAabTvzY3 UOgpLTqD9R0e0pttrg7lV4LHrR3aGpaSRFxTkSR0kbazf/GeTXoNIuS+n2KE7nZCau7/ eXf+E/0jL4Ko4yWlpxT6G/aJ4QNjyJW/COr+z363cN7ZfXFDSHhvINI1MbEY1FUurxrF 8GpYOd7glCxEpfmuESIvuBsEf6xugO2fDE8Pyc5UPEud8+ASHjK2BESfEuGC2ot/1dIz Spew== MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Thu, 27 Jun 2019 09:36:00 -0000 Message-ID: Subject: Re: allow EH to escape from GIMPLE_EH_ELSE ELSE block To: Alexandre Oliva Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg01732.txt.bz2 On Thu, Jun 27, 2019 at 10:18 AM Alexandre Oliva wrote: > > The only preexisting use of GIMPLE_EH_ELSE, for transactional memory > commits, did not allow exceptions to escape from the ELSE path. The > trick it uses to allow the ELSE path to see the propagating exception > does not work very well if the exception cleanup raises further > exceptions: the ELSE block is configured to handle exceptions in > itself. This confuses the heck out of CFG and EH cleanups. > > Basing the lowering context for the ELSE block on outer_state, rather > than this_state, gets us the expected enclosing handler. > > Regstrapped on x86_64-linux-gnu. Ok to install? Testcase? > > for gcc/ChangeLog > > * tree-eh.c (honor_protect_cleanup_actions): Use outer_ > rather than this_state as the lowering context for the ELSE > seq in a GIMPLE_EH_ELSE. > --- > gcc/tree-eh.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c > index 23c56b5661a1..4de09d1bf7b5 100644 > --- a/gcc/tree-eh.c > +++ b/gcc/tree-eh.c > @@ -1001,11 +1001,14 @@ honor_protect_cleanup_actions (struct leh_state *= outer_state, > gimple_try_set_cleanup (tf->top_p, gimple_eh_else_n_body (eh_else)= ); > finally =3D gimple_eh_else_e_body (eh_else); > > - /* Let the ELSE see the exception that's being processed. */ > - eh_region save_ehp =3D this_state->ehp_region; > - this_state->ehp_region =3D this_state->cur_region; > - lower_eh_constructs_1 (this_state, &finally); > - this_state->ehp_region =3D save_ehp; > + /* Let the ELSE see the exception that's being processed, but > + since the cleanup is outside the try block, process it with > + outer_state, otherwise it may be used as a cleanup for > + itself, and Bad Things (TM) ensue. */ > + eh_region save_ehp =3D outer_state->ehp_region; > + outer_state->ehp_region =3D this_state->cur_region; > + lower_eh_constructs_1 (outer_state, &finally); > + outer_state->ehp_region =3D save_ehp; > } > else > { > > -- > Alexandre Oliva, freedom fighter he/him https://FSFLA.org/blogs/lxo > Be the change, be Free! FSF Latin America board member > GNU Toolchain Engineer Free Software Evangelist > Hay que enGNUrecerse, pero sin perder la terGNUra jam=C3=A1s - Che GNUeva= ra