From patchwork Wed Jun 30 09:15:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 57388 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 ACAACB6EDF for ; Wed, 30 Jun 2010 19:16:25 +1000 (EST) Received: (qmail 5319 invoked by alias); 30 Jun 2010 09:16:22 -0000 Received: (qmail 5302 invoked by uid 22791); 30 Jun 2010 09:16:21 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Jun 2010 09:16:14 +0000 Received: (qmail 17995 invoked from network); 30 Jun 2010 09:16:12 -0000 Received: from unknown (HELO ?84.152.230.32?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 30 Jun 2010 09:16:12 -0000 Message-ID: <4C2B0B37.70209@codesourcery.com> Date: Wed, 30 Jun 2010 11:15:35 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100625 Thunderbird/3.0.5 MIME-Version: 1.0 To: GCC Patches Subject: Fix PR39799: missing uninitialized vars warning 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 This is a problem that was introduced with the fix for PR31081. Looking at that PR's history, it seems the inliner has problems with overlapping lifetimes for things where SSA_NAME_OCCURS_IN_ABNORMAL_PHI. The solution was to zero-initialize all uninitialized variables when inlining. This disables warnings for them, which is the regression in PR39799. I've bootstrapped and regression tested the patch below on i686-linux. This limits the zero-initialization to variables with SSA_NAME_OCCURS_IN_ABNORMAL_PHI. I doubt register pressure is an issue since we have another rtl-based init-regs pass. Ok? Bernd PR tree-optimization/39799 * tree-inline.c (remap_ssa_name): Initialize variable only if SSA_NAME_OCCURS_IN_ABNORMAL_PHI. PR tree-optimization/39799 * gcc.dg/uninit-17.c: New test. Index: tree-inline.c =================================================================== --- tree-inline.c (revision 161371) +++ tree-inline.c (working copy) @@ -234,6 +234,7 @@ remap_ssa_name (tree name, copy_body_dat regions of the CFG, but this is expensive to test. */ if (id->entry_bb && is_gimple_reg (SSA_NAME_VAR (name)) + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name) && TREE_CODE (SSA_NAME_VAR (name)) != PARM_DECL && (id->entry_bb != EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest || EDGE_COUNT (id->entry_bb->preds) != 1)) Index: testsuite/gcc.dg/uninit-17.c =================================================================== --- testsuite/gcc.dg/uninit-17.c (revision 0) +++ testsuite/gcc.dg/uninit-17.c (revision 0) @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +inline int foo(int x) +{ + return x; +} +static void bar(int a, int *ptr) +{ + do + { + int b; + if (b < 40) { + ptr[0] = b; /* { dg-warning "may be used uninitialized" } */ + } + b += 1; + ptr++; + } + while (--a != 0); +} +void foobar(int a, int *ptr) +{ + bar(foo(a), ptr); +} + +/* { dg-message "note: '\[^\n'\]*' was declared here" "note: expected" { target *-*-* } 0 } */