From patchwork Thu Nov 11 15:29:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 70824 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 ACA09B714E for ; Fri, 12 Nov 2010 02:30:06 +1100 (EST) Received: (qmail 29049 invoked by alias); 11 Nov 2010 15:30:02 -0000 Received: (qmail 29003 invoked by uid 22791); 11 Nov 2010 15:30:01 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Nov 2010 15:29:55 +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.13.8/8.13.8) with ESMTP id oABFTrkq027977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Nov 2010 10:29:53 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oABFTqOb011696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Nov 2010 10:29:53 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oABFTqGv025968; Thu, 11 Nov 2010 16:29:52 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oABFTqa3025967; Thu, 11 Nov 2010 16:29:52 +0100 Date: Thu, 11 Nov 2010 16:29:52 +0100 From: Jakub Jelinek To: Richard Henderson Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix expansion ICE with VOIDmode MEM (PR middle-end/46388) Message-ID: <20101111152952.GF29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20101110232124.GZ29412@tyan-ft48-01.lab.bos.redhat.com> <4CDB330E.7070002@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4CDB330E.7070002@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 On Wed, Nov 10, 2010 at 04:04:30PM -0800, Richard Henderson wrote: > On 11/10/2010 03:21 PM, Jakub Jelinek wrote: > > I think we just should avoid having VOIDmode MEM around whenever possible, > > the following patch fixes it by using the MEM_REF access mode instead > > (alternatively we could always use BLKmode for it). > > I prefer we create the mem with BLKmode. Here is that version, again bootstrapped/regtested on x86_64-linux and i686-linux and tested on the testcase with ia64-linux cross. Ok for trunk? 2010-11-11 Jakub Jelinek PR middle-end/46388 * expr.c (expand_assignment): If to_rtx is a VOIDmode MEM, use BLKmode mode for it. (expand_expr_real_1): Similarly for op0. * gcc.c-torture/compile/pr46388.c: New test. Jakub --- gcc/expr.c.jj 2010-11-09 13:58:30.000000000 +0100 +++ gcc/expr.c 2010-11-10 11:37:53.000000000 +0100 @@ -4260,11 +4260,16 @@ expand_assignment (tree to, tree from, b to_rtx = expand_normal (tem); /* If the bitfield is volatile, we want to access it in the - field's mode, not the computed mode. */ - if (volatilep - && GET_CODE (to_rtx) == MEM - && flag_strict_volatile_bitfields > 0) - to_rtx = adjust_address (to_rtx, mode1, 0); + field's mode, not the computed mode. + If a MEM has VOIDmode (external with incomplete type), + use BLKmode for it instead. */ + if (MEM_P (to_rtx)) + { + if (volatilep && flag_strict_volatile_bitfields > 0) + to_rtx = adjust_address (to_rtx, mode1, 0); + else if (GET_MODE (to_rtx) == VOIDmode) + to_rtx = adjust_address (to_rtx, BLKmode, 0); + } if (offset != 0) { @@ -9013,11 +9018,16 @@ expand_expr_real_1 (tree exp, rtx target /* If the bitfield is volatile, we want to access it in the - field's mode, not the computed mode. */ - if (volatilep - && GET_CODE (op0) == MEM - && flag_strict_volatile_bitfields > 0) - op0 = adjust_address (op0, mode1, 0); + field's mode, not the computed mode. + If a MEM has VOIDmode (external with incomplete type), + use BLKmode for it instead. */ + if (MEM_P (op0)) + { + if (volatilep && flag_strict_volatile_bitfields > 0) + op0 = adjust_address (op0, mode1, 0); + else if (GET_MODE (op0) == VOIDmode) + op0 = adjust_address (op0, BLKmode, 0); + } mode2 = CONSTANT_P (op0) ? TYPE_MODE (TREE_TYPE (tem)) : GET_MODE (op0); --- gcc/testsuite/gcc.c-torture/compile/pr46388.c.jj 2010-11-10 11:45:52.000000000 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr46388.c 2010-11-10 11:45:37.000000000 +0100 @@ -0,0 +1,14 @@ +/* PR middle-end/46388 */ + +struct S; +struct T +{ + struct S *t; +}; +extern struct S s, u; + +void +foo (void) +{ + ((struct T *) &u)->t = &s; +}