From patchwork Wed Dec 23 14:48:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 560558 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 BC769140C01 for ; Thu, 24 Dec 2015 01:48:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=aXlgoCTY; 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:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=KfMqGa4svSJloUQLi W68Tnsm98/1vjPDHVsIcT4q3GcmvDW475cmx3iP8ANMA7llXXKB5gWPJpiiK/MSv fRkEZFG31MUVA0S2QO2yZiz046XV6HLYl2acj6fnuR6AK+Cb7K1b1mMyGj4CJfYP B/HiFSDNAdPWBTX86n4KSJNa0g= 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:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=vLJZmaHpPj8TEbi+MCZu4+A nTkE=; b=aXlgoCTYBJqVcFUPS+T5XbiJMoRZhPd+UP2nghAC5MiJlwCjCc+r00e /0zT54oLPG6tSmcfLiu3l0m6wZAv82wF+h7jW+7GVer7F/BvuEiFhCDjVRb/e/fH rNwa19+G35m/l5LxvbTi/uv3hQCy1I0b7TQ7SZpM7MQyrnBu/VLc= Received: (qmail 29657 invoked by alias); 23 Dec 2015 14:48:43 -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 29636 invoked by uid 89); 23 Dec 2015 14:48:42 -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, 1, 15, base2, Hx-languages-length:2553 X-HELO: mail-qg0-f42.google.com Received: from mail-qg0-f42.google.com (HELO mail-qg0-f42.google.com) (209.85.192.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 23 Dec 2015 14:48:41 +0000 Received: by mail-qg0-f42.google.com with SMTP id k90so154976877qge.0 for ; Wed, 23 Dec 2015 06:48:41 -0800 (PST) X-Received: by 10.140.242.216 with SMTP id n207mr43037320qhc.37.1450882119419; Wed, 23 Dec 2015 06:48:39 -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 t187sm18074284qhc.40.2015.12.23.06.48.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Dec 2015 06:48:38 -0800 (PST) Subject: Re: varpool/constpool bug To: Jeff Law , GCC Patches References: <56758A2A.4090206@acm.org> <567856CE.90908@redhat.com> From: Nathan Sidwell Message-ID: <567AB446.107@acm.org> Date: Wed, 23 Dec 2015 09:48:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <567856CE.90908@redhat.com> On 12/21/15 14:45, Jeff Law wrote: > With some kind of comment in decl_in_symtab_p indicating why we need to check > and filter on !DECL_IN_CONSTANT_POOL this is OK. Done, thanks. (I half guessed HPPA might be such a port :) nathan 2015-12-23 Nathan Sidwell gcc/ * alias.c (compare_base_decls): Simplify in-symtab check. * cgraph.h (decl_in_symtab_p): Check DECL_IN_CONSTANT_POOL. testsuite/ * gcc.dg/alias-15.c: New. Index: alias.c =================================================================== --- alias.c (revision 231927) +++ alias.c (working copy) @@ -2038,13 +2038,12 @@ compare_base_decls (tree base1, tree bas if (base1 == base2) return 1; - bool in_symtab1 = decl_in_symtab_p (base1); - bool in_symtab2 = decl_in_symtab_p (base2); - /* Declarations of non-automatic variables may have aliases. All other decls are unique. */ - if (in_symtab1 != in_symtab2 || !in_symtab1) + if (!decl_in_symtab_p (base1) + || !decl_in_symtab_p (base2)) return 0; + ret = symtab_node::get_create (base1)->equal_address_to (symtab_node::get_create (base2), true); if (ret == 2) Index: cgraph.h =================================================================== --- cgraph.h (revision 231927) +++ cgraph.h (working copy) @@ -2294,13 +2294,19 @@ symtab_node::real_symbol_p (void) } /* Return true if DECL should have entry in symbol table if used. - Those are functions and static & external veriables*/ + Those are functions and static & external non-constpool variables. + We do not expect constant pool variables in the varpool, as they're + not related to other variables, and simply lazily inserting them + using the regular interface results in varpool thinking they are + externally provided -- which results in erroneous assembly emission + as an undefined decl. */ static inline bool decl_in_symtab_p (const_tree decl) { return (TREE_CODE (decl) == FUNCTION_DECL || (TREE_CODE (decl) == VAR_DECL + && !DECL_IN_CONSTANT_POOL (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))); } 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" } } */