From patchwork Fri Jun 25 11:43:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 56902 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 642C0B6F14 for ; Fri, 25 Jun 2010 21:43:23 +1000 (EST) Received: (qmail 18257 invoked by alias); 25 Jun 2010 11:43:21 -0000 Received: (qmail 18205 invoked by uid 22791); 25 Jun 2010 11:43:20 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 11:43:16 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5PBhFAC001268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 Jun 2010 07:43:15 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5PBhE5K022758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jun 2010 07:43:15 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5PBhuwr025058; Fri, 25 Jun 2010 13:43:56 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5PBhtv4025056; Fri, 25 Jun 2010 13:43:55 +0200 Date: Fri, 25 Jun 2010 13:43:55 +0200 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove vdefs when changing a normal call into noreturn call (PR tree-optimization/44539) Message-ID: <20100625114355.GI12443@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! When a call has VDEF, but doesn't have lhs and is through noreturn discovery changed into a noreturn call, we failed to remove the VDEF, which caused verification errors. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? Calling update_stmt unconditionally there isn't possible, as update_stmt adds the stmt into MODIFIED_NORETURN_CALLS and thus split_bbs_on_noreturn_calls hangs. If it has lhs or vdef, the first update_stmt call changes it and the next one won't call update_stmt anymore. 2010-06-25 Jakub Jelinek PR tree-optimization/44539 * tree-cfgcleanup.c (fixup_noreturn_call): Call update_stmt even when the call doesn't have LHS, but has VDEF. * gcc.dg/pr44539.c: New test. Jakub --- gcc/tree-cfgcleanup.c.jj 2010-06-14 07:44:24.000000000 +0200 +++ gcc/tree-cfgcleanup.c 2010-06-24 11:44:59.000000000 +0200 @@ -591,6 +591,9 @@ fixup_noreturn_call (gimple stmt) update_stmt (stmt); changed = true; } + /* Similarly remove VDEF if there is any. */ + else if (gimple_vdef (stmt)) + update_stmt (stmt); return changed; } --- gcc/testsuite/gcc.dg/pr44539.c.jj 2010-06-24 11:45:16.000000000 +0200 +++ gcc/testsuite/gcc.dg/pr44539.c 2010-06-24 11:44:26.000000000 +0200 @@ -0,0 +1,29 @@ +/* PR tree-optimization/44539 */ +/* { dg-do compile } */ +/* { dg-options "-ftracer -freorder-blocks -O2" } */ + +void bar (int file); +extern int baz (void); + +void noret1 () +{ + bar (0); + __builtin_exit (0); +} + +void noret2 () +{ + __builtin_exit (0); +} + +void bar (int i) +{ + if (baz ()) + noret1 (i); +} + +void foo (int i) +{ + if (~i) bar (i); + i ? noret1 () : noret2 (); +}