From patchwork Mon Jan 4 15:57:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 562443 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 A4B151402D8 for ; Tue, 5 Jan 2016 02:58:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=o6tdFWYz; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=YHk6YEJiH2tBMalev tE9NyrP10wGZ+5JE5zRWTo0/+oMv5QcxXOpeIZGhygM7yPN/rMQFQcerfxqrFhks PT5aLLI1Cex3yuUwo6ZUfMziAJJmie5cKZ6QLPxvhV0RnAn7KuoKxuvzCHq8NlE1 fr0W/e8+EHYL3tfYJtERn4cv+A= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=apOqAXYUgA5A4Y6SbJvXEVN 0W2c=; b=o6tdFWYzxdRAt/weh3YVxG3ndsBu0ptHrS97jO/8EjaXZ+te090mfOl fl/JKIogCHi1ul89mQO1mBVBHlIxRXVZJbOp7IZamgMsiC/LDRvWlwNwTm22FA0C 3riXDhmvQy9bodD5KtSkTTqDaMhyvomQZq76SCuHaRH4OJNam9I8= Received: (qmail 123485 invoked by alias); 4 Jan 2016 15:57:56 -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 123474 invoked by uid 89); 4 Jan 2016 15:57:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=bas, abc, lco, sk:compare X-HELO: mail-qg0-f52.google.com Received: from mail-qg0-f52.google.com (HELO mail-qg0-f52.google.com) (209.85.192.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 04 Jan 2016 15:57:54 +0000 Received: by mail-qg0-f52.google.com with SMTP id e32so166443827qgf.3 for ; Mon, 04 Jan 2016 07:57:54 -0800 (PST) X-Received: by 10.141.0.4 with SMTP id b4mr5139145qhd.23.1451923072627; Mon, 04 Jan 2016 07:57:52 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id v65sm11779253qhc.46.2016.01.04.07.57.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jan 2016 07:57:52 -0800 (PST) Subject: Re: varpool/constpool bug To: Jeff Law , GCC Patches References: <56758A2A.4090206@acm.org> <567856CE.90908@redhat.com> <567AB446.107@acm.org> <567AE728.7020003@acm.org> Cc: seurer@linux.vnet.ibm.com From: Nathan Sidwell Message-ID: <568A967F.4060203@acm.org> Date: Mon, 4 Jan 2016 10:57:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <567AE728.7020003@acm.org> My patch to stop constant pool objects accidentally ending up in the varpool caused problems with (at least) powerpc. (https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02100.html) Hence reverted. This patch changes compare_base_decls to simply use the varpool getter, rather than get_create. We still need the preceding decl_in_symtab_p to filter out decls that should never be in the varpool (the getter has an assert to check you're not trying to abuse it). ok? nathan 2016-01-04 Nathan Sidwell gcc/ * alias.c (compare_base_decls): Use symtab_node::get. gcc/testsuite/ * gcc.dg/alias-15.c: New. Index: alias.c =================================================================== --- alias.c (revision 232057) +++ alias.c (working copy) @@ -2044,8 +2044,15 @@ compare_base_decls (tree base1, tree bas || !decl_in_symtab_p (base2)) return 0; - ret = symtab_node::get_create (base1)->equal_address_to - (symtab_node::get_create (base2), true); + /* Don't cause symbols to be inserted by the act of checking. */ + symtab_node *node1 = symtab_node::get (base1); + if (!node1) + return 0; + symtab_node *node2 = symtab_node::get (base2); + if (!node2) + return 0; + + ret = node1->equal_address_to (node2, true); if (ret == 2) return -1; return ret; Index: testsuite/gcc.dg/alias-15.c =================================================================== --- testsuite/gcc.dg/alias-15.c (revision 0) +++ testsuite/gcc.dg/alias-15.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -fdump-ipa-cgraph" } */ + +/* RTL-level CSE shouldn't introduce LCO (for the string) into varpool */ +char *p; + +void foo () +{ + p = "abc\n"; + + while (*p != '\n') + p++; +} + +/* { dg-final { scan-ipa-dump-not "LC0" "cgraph" } } */