From patchwork Thu Sep 3 08:39:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 513868 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 38F9D140273 for ; Thu, 3 Sep 2015 18:39:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xwR7LlNd; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=TIb5e5TbRpZ/2VATp6UCKAzKWjvNZmWB2umood1CJ4hlHwzfqlslJ 0SgYuz0mALE/hOjMzL43t15DVptb2SrTaCHZyvdElg3OhJPe6rxejTDlMJL6bxQH jEsW9bRVoIgx5qj87KIFdqWr5IhZMX5Opr3rUZQt0PXYkl4skm5Pxo= 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=B3NovskMAv7Z/SPbwda00WPbNzM=; b=xwR7LlNdmwo2g2WpvAbH2xkj56NP 3tmK0rU4j6+AK2LHxZSkbnDk71N7MfeCTId3K9fRp6S6GD9MaA5Ssvc5bzD9W618 mDPpVgOlQndbI5os4gMUxaQEgeJ8tZvOsCvyBC57PUad2dEoQ4tUY2Qpfk/HC9Ih bWEJnndGS96PbC0= Received: (qmail 36068 invoked by alias); 3 Sep 2015 08:39:36 -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 36056 invoked by uid 89); 3 Sep 2015 08:39:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Sep 2015 08:39:33 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-2-R9QzY8lnQSi1bVi6CnfRSA-1; Thu, 03 Sep 2015 09:39:28 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 3 Sep 2015 09:39:27 +0100 From: Richard Sandiford To: Rainer Orth Mail-Followup-To: Rainer Orth , Jeff Law , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: Fix reload1.c warning for some targets References: <87d1z1kedx.fsf@e105548-lin.cambridge.arm.com> <55CB7F88.5040104@redhat.com> <87bnebc4or.fsf@googlemail.com> Date: Thu, 03 Sep 2015 09:39:27 +0100 In-Reply-To: (Rainer Orth's message of "Mon, 24 Aug 2015 12:50:46 +0200") Message-ID: <87lhcn6gn4.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: R9QzY8lnQSi1bVi6CnfRSA-1 Rainer Orth writes: > Richard Sandiford writes: >> Jeff Law writes: >>> On 08/05/2015 08:18 AM, Richard Sandiford wrote: >>>> Building some targets results in a warning about orig_dup[i] potentially >>>> being used uninitialised. I think the warning is fair, since it isn't >>>> obvious that the reog_data-based loop bound remains unchanged between: >>>> >>>> for (i = 0; i < recog_data.n_dups; i++) >>>> orig_dup[i] = *recog_data.dup_loc[i]; >>>> >>>> and: >>>> >>>> for (i = 0; i < recog_data.n_dups; i++) >>>> *recog_data.dup_loc[i] = orig_dup[i]; >>>> >>>> Tested on x86_64-linux-gnu. OK to install? >>>> >>>> Thanks, >>>> Richard >>>> >>>> gcc/ >>>> * reload1.c (elimination_costs_in_insn): Make it obvious to the >>>> compiler that the n_dups and n_operands loop bounds are invariant. >>> So thinking more about this, I think the best way forward is to: >>> >>> 1. Create a new BZ with the false positive extracted from c#4. >>> >>> 2. Install your patch and close 55035. >>> >>> I'll take care of #1, you can handle #2. >> >> Thanks, I've now done #2. > > Unfortunately the patch broke sparcv9-sun-solaris2* (only, > sparc-sun-solaris2* is fine) bootstrap: > > /vol/gcc/src/hg/trunk/local/gcc/reload1.c: In function 'void elimination_costs_in_insn(rtx_insn*)': > /vol/gcc/src/hg/trunk/local/gcc/reload1.c:3772:41: error: 'orig_dup[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized] > *recog_data.dup_loc[i] = orig_dup[i]; > ^ > /vol/gcc/src/hg/trunk/local/gcc/reload1.c:3772:41: error: 'orig_dup[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > Rainer Sorry for the slow reply. I did try to coerce the current uninit pass to handle this case, but the patch I ended up with only worked by accident because of the strange way in which the pass handles limit cases. (If we have more than MAX_NUM_CHAINS chains, it silently drops the excess chains and continues regardless, so it's quite easy to come up with cases where the predicates for either the definition or the use consider an arbitrary subset of the actual conditions.) It sounds like Jeff has a much more radical rewrite in mind, so for now how about just turning -Wmaybe-uninitialized into a warning for this function? The patch will mean that it becomes a warning even if someone turns off warnings on the command line, but I don't think that's important. Bootstrapped and regression-tested on x86_64-linux-gnu. Also tested with a cross-compiler to sparc-linux-gnu (which also triggered the warning for me). Tested that clang could still compile the file. OK to install? gcc/ * reload1.c (elimination_costs_in_insn): Locally turn -Wmaybe-uninitialized into a warning. diff --git a/gcc/reload1.c b/gcc/reload1.c index ad243e3..c7cc37b 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -3636,6 +3636,8 @@ eliminate_regs_in_insn (rtx_insn *insn, int replace) eliminations in its operands and record cases where eliminating a reg with an invariant equivalence would add extra cost. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wmaybe-uninitialized" static void elimination_costs_in_insn (rtx_insn *insn) { @@ -3785,6 +3787,7 @@ elimination_costs_in_insn (rtx_insn *insn) return; } +#pragma GCC diagnostic pop /* Loop through all elimination pairs. Recalculate the number not at initial offset.