From patchwork Tue Sep 27 14:26:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116608 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 07F7DB6F70 for ; Wed, 28 Sep 2011 00:26:25 +1000 (EST) Received: (qmail 31245 invoked by alias); 27 Sep 2011 14:26:23 -0000 Received: (qmail 31237 invoked by uid 22791); 27 Sep 2011 14:26:23 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Sep 2011 14:26:06 +0000 Received: by wwf10 with SMTP id 10so6162201wwf.8 for ; Tue, 27 Sep 2011 07:26:05 -0700 (PDT) Received: by 10.216.88.140 with SMTP id a12mr8501804wef.82.1317133565196; Tue, 27 Sep 2011 07:26:05 -0700 (PDT) Received: from richards-thinkpad.stglab.manchester.uk.ibm.com (rsandifo.gotadsl.co.uk. [82.133.89.107]) by mx.google.com with ESMTPS id fy13sm8348018wbb.18.2011.09.27.07.26.04 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Sep 2011 07:26:04 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, Martin Jambor , richard.sandiford@linaro.org Cc: Martin Jambor Subject: Fix type of SRAed enum accesses Date: Tue, 27 Sep 2011 15:26:03 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 This patch fixes a miscompilation of stage1 c-parser.o in an ARM bootstrap. When an access to an enum field was SRAed, a component ref used the type of the integer temporary variable instead of the type of the enum. It therefore didn't alias other accesses to the same structure, and was scheduled after a copy-load. Tested on x86_64-linux-gnu, and by verifying that c-parser.o is correctly compiled for ARM after the patch. Martin says he's going to test on ia64 too (thanks) -- I'll add 50326 to the changelog if that goes OK. OK to install if there are no regressions on ia64? Richard gcc/ PR middle-end/50386 * tree-sra.c (build_ref_for_model): Use the type of the field as the type of the COMPONENT_REF. Index: gcc/tree-sra.c =================================================================== --- gcc/tree-sra.c 2011-09-12 09:09:34.000000000 +0100 +++ gcc/tree-sra.c 2011-09-27 14:09:45.379960167 +0100 @@ -1504,7 +1504,7 @@ build_ref_for_model (location_t loc, tre offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (fld)); exp_type = TREE_TYPE (TREE_OPERAND (model->expr, 0)); t = build_ref_for_offset (loc, base, offset, exp_type, gsi, insert_after); - return fold_build3_loc (loc, COMPONENT_REF, model->type, t, fld, + return fold_build3_loc (loc, COMPONENT_REF, TREE_TYPE (fld), t, fld, TREE_OPERAND (model->expr, 2)); } else