From patchwork Tue Jan 28 22:48:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 314865 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 284182C0078 for ; Wed, 29 Jan 2014 09:48:35 +1100 (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:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=ROMSR/YUUszYOiK1WwcgG7Waiw7M4a/iT8ErsxmNB/d EqjyY2LD8CnuHBeWAHOjXDr9qdQzR/Z8X84Y5z/avK3/x9W7r85SJG996x4THqdh d9+6P7XXne1bw7eLmQniHhX+w5ulF4w2GA5Ff1ei2xi5k7BJzoPZUgEw8v1QX6P4 = 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:subject:message-id:reply-to:mime-version:content-type; s=default; bh=1m+m3S87Nm/P7L41fkwFcsk7eyU=; b=J6BM9HBA/ayO0LFvK cxodu/iG/ypRZ0GH3YnDDwyD31BWfdMDScRCCZw3yhcS8v6TABhdPTE7yfwXxpsL N3BmfsVs570WFjuyr/T96iG1nv/KlbpJlQVY3BzkQYtpNU5MPo8I65CSeWWgRsbZ wWeymZYMk6jRQr7jKrBBXy6XuY= Received: (qmail 8545 invoked by alias); 28 Jan 2014 22:48:29 -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 8527 invoked by uid 89); 28 Jan 2014 22:48:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jan 2014 22:48:27 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0SMmQb7002392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Jan 2014 17:48:26 -0500 Received: from tucnak.zalov.cz (vpn1-5-215.ams2.redhat.com [10.36.5.215]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0SMmOQH032295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 28 Jan 2014 17:48:25 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id s0SMmNcI006130 for ; Tue, 28 Jan 2014 23:48:23 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id s0SMmN8S006129 for gcc-patches@gcc.gnu.org; Tue, 28 Jan 2014 23:48:23 +0100 Date: Tue, 28 Jan 2014 23:48:23 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] FIx a valgrind reported issue in build tools (PR other/58712) Message-ID: <20140128224823.GR892@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi! I've started an --enable-checking=valgrind bootstrap during the weekend, but only on Sunday afternoon and thus killed it on Monday morning, so it didn't get very far, but still reported a problem where the build tools had uninitialized memory use in copy_rtx: case CLOBBER: /* Share clobbers of hard registers (like cc0), but do not share * pseudo reg clobbers or clobbers of hard registers that originated as pseudos. This is needed to allow safe register renaming. */ if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0))) return orig; - ORIGINAL_REGNO was uninitialized. The problem is that read_rtx_code uses rtx_alloc, which clears only the first int in the structure (header), and then ignores the fields with 0 format character. For ORIGINAL_REGNO, we want to set it to REGNO, for others IMHO it is best to just clear those fields. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2014-01-28 Jakub Jelinek PR other/58712 * read-rtl.c (read_rtx_code): Clear all of RTX_CODE_SIZE (code). For REGs set ORIGINAL_REGNO. Jakub --- gcc/read-rtl.c.jj 2014-01-03 11:40:57.000000000 +0100 +++ gcc/read-rtl.c 2014-01-27 10:01:44.154527266 +0100 @@ -1131,6 +1131,7 @@ read_rtx_code (const char *code_name) /* If we end up with an insn expression then we free this space below. */ return_rtx = rtx_alloc (code); format_ptr = GET_RTX_FORMAT (code); + memset (return_rtx, 0, RTX_CODE_SIZE (code)); PUT_CODE (return_rtx, code); if (iterator) @@ -1154,6 +1155,8 @@ read_rtx_code (const char *code_name) /* 0 means a field for internal use only. Don't expect it to be present in the input. */ case '0': + if (code == REG) + ORIGINAL_REGNO (return_rtx) = REGNO (return_rtx); break; case 'e':