From patchwork Thu Apr 25 22:02:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 239601 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 573D52C00CB for ; Fri, 26 Apr 2013 08:03:15 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=Jp89rTLmIXTlOalvfTGjh4+PdQcQQ ZRMmooYressQTb6siyr41dXGFjBByKklNoOtItxnBKjafKFtFGtp0xLTP7YDh2Ry pmhras8NfDi+kcvDKTqKVDFBHN7pmScGQykNCnxL923ZUeH6xCAVyZSrQhWJmJML 6sjDtyicTBh43c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=Wa4YVIiHyMjIrdqTbwNKNGnEjTs=; b=t/G wIXgC7H+qHFOCrwEQ0GrAizExiViJMrU9HoViOgCWK86W9byiDuK1fkdqEE4GYKm OV920RTPhZBQriP1jdghUKOCNI3JRdMgirtpxC0WE24zibWr9QAw/icbXIV9YHXX yn9xFJVhB5snE6MoozQdnMWjqJZkuVqnZ3VUbbI4= Received: (qmail 391 invoked by alias); 25 Apr 2013 22:03:06 -0000 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 Received: (qmail 379 invoked by uid 89); 25 Apr 2013 22:03:06 -0000 X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS, TW_TJ, TW_TM autolearn=no version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Apr 2013 22:03:05 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3PM34Bu013499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Apr 2013 18:03:04 -0400 Received: from zalov.cz (vpn-61-36.rdu2.redhat.com [10.10.61.36]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3PM32oG016428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Apr 2013 18:03:03 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r3PM30sR010669; Fri, 26 Apr 2013 00:03:01 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r3PM2xZP010668; Fri, 26 Apr 2013 00:02:59 +0200 Date: Fri, 26 Apr 2013 00:02:58 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix bootstrap with go (uninit warning with ab edges) Message-ID: <20130425220258.GL28963@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! Bootstrap currently fails in libgo, there are false positive warnings that ({anonymous}) is uninitialized in multiple places. The testcase below reproduces this issue too. The problem is that the ab edges to setjmp call are added conservatively, thus they can be added even from calls before the setjmp call, that are never executed after the setjmp, and in their bb's some variables might not be initialized yet, even if their initialization dominates the setjmp call. As discussed on IRC, the following patch let us ignore the SSA_NAMEs on such abnormal edges. Perhaps later on we could try to do something for the common case where there is exactly one setjmp call or exactly one nonlocal goto label in a function, we could then avoid creating abnormal edges that aren't needed (calls that don't appear on any path from the single setjmp call to exit don't need to have ab edge to it). Bootstrapped/regtested on x86_64-linux and i686-linux (including go), ok for trunk? 2013-04-25 Jakub Jelinek * tree-ssa-uninit.c (compute_uninit_opnds_pos): In functions with nonlocal goto receivers or returns twice calls, ignore unininitialized values from abnormal edges to nl goto receiver or returns twice call. * gcc.dg/setjmp-5.c: New test. Jakub --- gcc/tree-ssa-uninit.c.jj 2013-03-04 10:37:48.000000000 +0100 +++ gcc/tree-ssa-uninit.c 2013-04-25 17:52:55.215166853 +0200 @@ -151,7 +151,21 @@ compute_uninit_opnds_pos (gimple phi) if (TREE_CODE (op) == SSA_NAME && ssa_undefined_value_p (op) && !can_skip_redundant_opnd (op, phi)) - MASK_SET_BIT (uninit_opnds, i); + { + /* Ignore SSA_NAMEs on abnormal edges to setjmp + or nonlocal goto receiver. */ + if (cfun->has_nonlocal_label || cfun->calls_setjmp) + { + edge e = gimple_phi_arg_edge (phi, i); + if (e->flags & EDGE_ABNORMAL) + { + gimple last = last_stmt (e->src); + if (last && stmt_can_make_abnormal_goto (last)) + continue; + } + } + MASK_SET_BIT (uninit_opnds, i); + } } return uninit_opnds; } --- gcc/testsuite/gcc.dg/setjmp-5.c.jj 2013-04-25 17:54:49.679559650 +0200 +++ gcc/testsuite/gcc.dg/setjmp-5.c 2013-04-25 17:55:08.084460447 +0200 @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +#include + +void bar (int); + +jmp_buf buf; +int v; + +void +foo (void) +{ + int i; + bar (0); + bar (1); + i = 5; + int j = setjmp (buf); + if (j == 0) + bar (2); + v = i; /* { dg-bogus "may be used uninitialized in this function" } */ +}