From patchwork Tue Jun 2 14:19:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bennett X-Patchwork-Id: 479508 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 35BB61412E6 for ; Wed, 3 Jun 2015 00:20:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=sydW5vRc; 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:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=DgZ PDPim2DIwy6kvOlwgdAd4HdgJUDgX7T1WJw3LMxRazg5lZkyvEGwsqWzBPlUSrkA 7wAz4GSpBCmZF9kD8A5619L9O3+PGOQJ9z1kJh8qFKOmGcyT12zl1SJzgkoK04pR ihYdjxxPtYXfp8f/J2hBfY/28Bg+nVOrW9N1o/7c= 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:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=/CMtWzQLQ kqhWEcyxnQzEk9+2qU=; b=sydW5vRc2T4jgu3nz9+gOo0RsP2JE6dmAGVyVv6/R M6ro5VBpMhAZgouh4ii1c4WW6FQAA5JubXBgoFU+16gcqrlgbTiV4SvvT6KRslJC Yodv8uhqtELNNaCsCgPoGw9RCxd29zvokpIZYzaA0qcvcII+drlIQmvBoSv9qM8D Ng= Received: (qmail 89162 invoked by alias); 2 Jun 2015 14:19:57 -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 89149 invoked by uid 89); 2 Jun 2015 14:19:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Jun 2015 14:19:56 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 6384FA93AB4C1 for ; Tue, 2 Jun 2015 15:19:50 +0100 (IST) Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 2 Jun 2015 15:19:53 +0100 Received: from LEMAIL01.le.imgtec.org ([fe80::5ae:ee16:f4b9:cda9]) by LEMAIL01.le.imgtec.org ([fe80::5ae:ee16:f4b9:cda9%17]) with mapi id 14.03.0210.002; Tue, 2 Jun 2015 15:19:53 +0100 From: Andrew Bennett To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] Update check after force_const_mem call in the plus_constant function to see if the value returned is not a NULL_RTX. Date: Tue, 2 Jun 2015 14:19:52 +0000 Message-ID: <0DA23CC379F5F945ACB41CF394B9827720FC1045@LEMAIL01.le.imgtec.org> MIME-Version: 1.0 X-IsSubscribed: yes Hi, In the plus_constant function in explow.c the code to update a constant pool value does not deal with the case where the value returned from force_const_mem is a NULL_RTX. This occurs for the MIPS target because its cannot_force_const_mem target function does not allow constants (so that the move expanders can deal with them later on), this then causes the force_const_mem function to return a NULL_RTX and then causes GCC to segmentation fault when calling the memory_address_p function. The fix is to add a check that the tem variable is not a NULL_RTX before the memory_address_p function call. I have tested the fix on the mips-mti-linux-gnu target for both mips32r2 o32 and mips64r2 n64 and there have been no regressions. The patch and ChangeLog are below. Ok to commit? Many thanks, Andrew * explow.c (plus_constant): Update check after force_const_mem call to see if the value returned is not a NULL_RTX. diff --git a/gcc/explow.c b/gcc/explow.c index d1a2bf8..8745aea 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -132,7 +132,9 @@ plus_constant (machine_mode mode, rtx x, HOST_WIDE_INT c, { tem = plus_constant (mode, get_pool_constant (XEXP (x, 0)), c); tem = force_const_mem (GET_MODE (x), tem); - if (memory_address_p (GET_MODE (tem), XEXP (tem, 0))) + /* Targets may disallow some constants in the constant pool, thus + force_const_mem may return NULL_RTX. */ + if (tem && memory_address_p (GET_MODE (tem), XEXP (tem, 0))) return tem; } break;