From patchwork Sat Aug 13 10:10:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 109928 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 116C8B6F18 for ; Sat, 13 Aug 2011 20:10:42 +1000 (EST) Received: (qmail 6098 invoked by alias); 13 Aug 2011 10:10:39 -0000 Received: (qmail 6088 invoked by uid 22791); 13 Aug 2011 10:10:38 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_CP, TW_TX, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-ww0-f41.google.com (HELO mail-ww0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Aug 2011 10:10:23 +0000 Received: by wwj26 with SMTP id 26so309257wwj.2 for ; Sat, 13 Aug 2011 03:10:22 -0700 (PDT) Received: by 10.227.173.7 with SMTP id n7mr1758780wbz.62.1313230222414; Sat, 13 Aug 2011 03:10:22 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id 8sm2968109wbx.34.2011.08.13.03.10.20 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 13 Aug 2011 03:10:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: Make genattrtab.c create unique symbol_refs Date: Sat, 13 Aug 2011 11:10:14 +0100 Message-ID: <87ty9l39mh.fsf@firetop.home> 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 rtx_equal_p uses: case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); to check whether two symbol_refs are equal. This means that genattrtab, which uses rtx_equal_p, must create unique strings for them. attr_rtx has code to create unique strings, and I think it originally handled symbol_refs. However, it still assumes that only "s" rtxes are of interest, whereas symbol_ref is now "s00" (decl and flags). Fixed with the patch below. The attr_string patch ensures that we preserve #line information for the unique strings. (We'll effectively pick the first occurence, which should be OK for most cases.) As explained in the next patch, this doesn't actually bring any benefit on its own, but it is needed by that patch. Tested on x86_64-linux-gnu and mips64-linux-gnu. OK to install? Richard gcc/ * genattrtab.c (attr_rtx_1): Hash SYMBOL_REFs. (attr_string): Use copy_md_ptr_loc. Index: gcc/genattrtab.c =================================================================== --- gcc/genattrtab.c 2011-07-23 10:03:35.000000000 +0100 +++ gcc/genattrtab.c 2011-07-23 10:34:20.000000000 +0100 @@ -433,8 +433,9 @@ attr_rtx_1 (enum rtx_code code, va_list XEXP (rt_val, 1) = arg1; } } - else if (GET_RTX_LENGTH (code) == 1 - && GET_RTX_FORMAT (code)[0] == 's') + else if (code == SYMBOL_REF + || (GET_RTX_LENGTH (code) == 1 + && GET_RTX_FORMAT (code)[0] == 's')) { char *arg0 = va_arg (p, char *); @@ -452,6 +453,11 @@ attr_rtx_1 (enum rtx_code code, va_list rtl_obstack = hash_obstack; rt_val = rtx_alloc (code); XSTR (rt_val, 0) = arg0; + if (code == SYMBOL_REF) + { + X0EXP (rt_val, 1) = NULL_RTX; + X0EXP (rt_val, 2) = NULL_RTX; + } } } else if (GET_RTX_LENGTH (code) == 2 @@ -610,6 +616,7 @@ attr_string (const char *str, int len) memcpy (new_str, str, len); new_str[len] = '\0'; attr_hash_add_string (hashcode, new_str); + copy_md_ptr_loc (new_str, str); return new_str; /* Return the new string. */ }