From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53478 invoked by alias); 26 Jul 2017 07:52:40 -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 53392 invoked by uid 89); 26 Jul 2017 07:52:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-lf0-f49.google.com Received: from mail-lf0-f49.google.com (HELO mail-lf0-f49.google.com) (209.85.215.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Jul 2017 07:52:38 +0000 Received: by mail-lf0-f49.google.com with SMTP id g25so61315842lfh.1 for ; Wed, 26 Jul 2017 00:52:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=wSn8ZJgmBYIZDrLMgInAnyj2J7pQSlM5PFt1C63ms10=; b=BXwAPXca33nOHURy4y2dYjCEFw27mQ2+jKUPtfNJsVaPzhJhNz5uvpiClguJlA6eQV +YPbdmv76JOFO3/pXQyYU+gY5Bs2PF6PzJKeJqO9xEUCPBU+mD1TUHNlzC9OIhzW91cy Sslccmet44nzJS2NRmdCgNI8WJELaSI+FHpxVfZkZxXuzrIoJXly8D9mSk3Z0DrskcOe b4QlOg4qWwiWL0eVTUzGYIRsfKnB3tWLXpYbsAnLDl99swUqi1dIzNeRCYbhj1QwixdF ilTySTLbdDiu4wXXYNG0gCnlAJFGPGfnEyaF/A6kgdIti6sNmrbX47ZoDFGmbjX/bOc9 eDbw== X-Gm-Message-State: AIVw113PBYq7sKRd0J24g3Rbj0Z5fkGhA83NYimR52ppfPdTuCnUkAXZ h2CatLiuk3LQ64y75cwFKSRJ6lQjMQ== X-Received: by 10.46.9.214 with SMTP id 205mr48680ljj.180.1501055555686; Wed, 26 Jul 2017 00:52:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.31.134 with HTTP; Wed, 26 Jul 2017 00:52:35 -0700 (PDT) In-Reply-To: <2663014.h6Leadj67V@arcturus.home> References: <2663014.h6Leadj67V@arcturus.home> From: Richard Biener Date: Wed, 26 Jul 2017 07:52:00 -0000 Message-ID: Subject: Re: Fix thinko in gimple_assign_set_rhs_with_ops To: Eric Botcazou Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg01630.txt.bz2 On Tue, Jul 25, 2017 at 3:59 PM, Eric Botcazou wrote: > The attached fix to the Ada front-end introduces a regression in the ACATS > testsuite for cb4009a. The backtrace is: > > #0 operation_could_trap_helper_p(tree_code, bool, bool, bool, bool, > tree_node*, bool*) () at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2439 > #1 0x00000000012946d7 in stmt_could_throw_1_p (stmt=) > at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2759 > #2 stmt_could_throw_p(gimple*) [clone .part.186] () > at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2809 > #3 0x0000000001295f28 in stmt_could_throw_p (stmt=0x7ffff6c5d420) > at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2924 > #4 maybe_clean_or_replace_eh_stmt (old_stmt=old_stmt@entry=0x7ffff6c565d8, > new_stmt=new_stmt@entry=0x7ffff6c5d420) > at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2908 > #5 0x0000000000fd8a0b in gsi_replace(gimple_stmt_iterator*, gimple*, bool) () > at /home/eric/gnat/gnat-head/src/gcc/gimple-iterator.c:447 > #6 0x0000000000fd14af in > gimple_assign_set_rhs_with_ops(gimple_stmt_iterator*, tree_code, tree_node*, > tree_node*, tree_node*) () > at /home/eric/gnat/gnat-head/src/gcc/gimple.c:1616 > #7 0x0000000000fe7af7 in replace_stmt_with_simplification (inplace=false, > seq=0x7fffffffd818, ops=0x7fffffffd820, rcode=..., gsi=0x7fffffffd8e0) > at /home/eric/gnat/gnat-head/src/gcc/gimple-fold.c:4151 > #8 fold_stmt_1(gimple_stmt_iterator*, bool, tree_node* (*)(tree_node*)) () > at /home/eric/gnat/gnat-head/src/gcc/gimple-fold.c:4462 > #9 0x0000000000fe961a in fold_stmt (gsi=gsi@entry=0x7fffffffd8e0, > valueize=valueize@entry=0x1331170 ) > at /home/eric/gnat/gnat-head/src/gcc/gimple-fold.c:4689 > > The folding is turning a TRUNC_DIV_EXPR into a COND_EXPR and the code does: > > /* If the new CODE needs more operands, allocate a new statement. */ > if (gimple_num_ops (stmt) < new_rhs_ops + 1) > { > tree lhs = gimple_assign_lhs (stmt); > gimple *new_stmt = gimple_alloc (gimple_code (stmt), new_rhs_ops + 1); > memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); > gimple_init_singleton (new_stmt); > gsi_replace (gsi, new_stmt, true); > stmt = new_stmt; > > /* The LHS needs to be reset as this also changes the SSA name > on the LHS. */ > gimple_assign_set_lhs (stmt, lhs); > } > > i.e it asks gsi_replace to update EH info, which doesn't work since the new > statement is dummy at this point. Fixed by passing false instead of true. > > Bootstrapped/regtested on x86_64-suse-linux, applied on mainline as obvious. I think we should get rid of that update-EH-info flag, always assuming false. This is IMHO a too low-level interface to do this (and we lack a gsi_replace_without_update) Not sure if you're willing to do this kind of cleanup ;) Richard. > > 2017-07-25 Eric Botcazou > > * gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace > to update EH info here. > > > 2017-07-25 Javier Miranda > > ada/ > * checks.adb (Apply_Divide_Checks): Ensure that operands are not > evaluated twice. > > > 2017-07-25 Eric Botcazou > > testsuite/ > * gnat.dg/opt66.adb: New test. > > > -- > Eric Botcazou