From patchwork Tue Apr 28 08:39:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schulze Frielinghaus X-Patchwork-Id: 1278348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=MkGJc5y2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49BFW10snnz9sPF for ; Tue, 28 Apr 2020 18:41:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 325F43851C04; Tue, 28 Apr 2020 08:41:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 325F43851C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588063301; bh=cKbTdxLfkeyythJi+FD0ARQJuFz0MSGbq03PFCLie1c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MkGJc5y2nDNjayBWZqBgNrq/YYD7Sq7rFhDL+ZZ5QjGm7ETghPjbvaPPzELHVAPy/ qXl5rKFMs+yfvUeIBIdrUKpWsFIXfRY1wP2iGAAsWOoDuc5x47WqoYb+MaJnXLrfFq 5TOTemZne29KlqXQrYcyB9PUVQf9On0rEQ+fg50I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 070FA3851C02 for ; Tue, 28 Apr 2020 08:41:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 070FA3851C02 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03S8Ww11088249 for ; Tue, 28 Apr 2020 04:41:38 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 30metw7286-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Apr 2020 04:41:38 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 03S8Z6Lj022190 for ; Tue, 28 Apr 2020 08:41:36 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03ams.nl.ibm.com with ESMTP id 30mcu5npjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Apr 2020 08:41:36 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03S8fYKK62652568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 28 Apr 2020 08:41:34 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9917AA4059 for ; Tue, 28 Apr 2020 08:41:34 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C5EBA4051 for ; Tue, 28 Apr 2020 08:41:34 +0000 (GMT) Received: from m35lp38.lnxne.boe (unknown [9.152.108.100]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS for ; Tue, 28 Apr 2020 08:41:34 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] var-tracking.c: Fix possible use of uninitialized variable pre Date: Tue, 28 Apr 2020 10:39:35 +0200 Message-Id: <20200428083934.1012916-1-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-28_03:2020-04-27, 2020-04-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=920 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004280070 X-Spam-Status: No, score=-22.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Stefan Schulze Frielinghaus via Gcc-patches From: Stefan Schulze Frielinghaus Reply-To: Stefan Schulze Frielinghaus Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" While bootstrapping GCC on S/390 the following warning/error is raised: gcc/var-tracking.c:10239:34: error: 'pre' may be used uninitialized in this function [-Werror=maybe-uninitialized] 10239 | VTI (bb)->out.stack_adjust += pre; | ^ The lines of interest are: HOST_WIDE_INT pre, post = 0; // ... if (!frame_pointer_needed) { insn_stack_adjust_offset_pre_post (insn, &pre, &post); // ... } // ... adjust_insn (bb, insn); if (!frame_pointer_needed && pre) VTI (bb)->out.stack_adjust += pre; Both if statements depend on global variable frame_pointer_needed. In function insn_stack_adjust_offset_pre_post local variable pre is initialized. The problematic part is the function call between both if statements. Since adjust_insn also calls functions which are defined in a different compilation unit, we are not able to prove that global variable frame_pointer_needed is not altered by adjust_insn and its siblings. Thus we must assume that frame_pointer_needed may be true before the call and false afterwards which renders the warning true (admitted the location hint is not totally perfect). By initialising pre we silence the warning. Bootstrapped and regtested on S/390. Ok for master? gcc/ChangeLog: 2020-04-28 Stefan Schulze Frielinghaus * var-tracking.c (vt_initialize): Initialize local variable pre. --- gcc/var-tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 0d39326aa63..f693a4f83fe 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -10171,7 +10171,7 @@ vt_initialize (void) FOR_EACH_BB_FN (bb, cfun) { rtx_insn *insn; - HOST_WIDE_INT pre, post = 0; + HOST_WIDE_INT pre = 0, post = 0; basic_block first_bb, last_bb; if (MAY_HAVE_DEBUG_BIND_INSNS)