From patchwork Thu Nov 28 12:02:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 294870 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 513632C00A6 for ; Thu, 28 Nov 2013 23:03:11 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=LngdghstpUAb3O+FdIgDNyyrLdINyik/ALYoldPfeM1qff02p+ewR aK8geSkhkYgYD9MxOQS09gOw4Kuf9cDIAkdjBHDp6WGj+3YV8AE94hE+Ew2HkR4N ePhSj/iXvlV676Qano3WwmTEpWFgomn5YI4ByHsZ0GG1neQVmLnRHQ= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=oLT/kOxICuoIes7faPi+3W08+lA=; b=F9nRCF6zPXjm+KWWvswB F3gvgO47nCYO7WFxHQ2DujpzHl5TgYh8iiplNmO1L/XgOogzrvNA1h5w2jEr1vld hs6cZRHPYVfUZbqhAzw8IPrNZ1Y7gYjBmhfy3rcQnSmnxzwrFJajHUA4QDXl5x6B fuGSaknLpnNM4QXKnN14+gY= Received: (qmail 4672 invoked by alias); 28 Nov 2013 12:02:52 -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 4471 invoked by uid 89); 28 Nov 2013 12:02:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from Unknown (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Nov 2013 12:02:50 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B0D9EA7D41 for ; Thu, 28 Nov 2013 13:02:42 +0100 (CET) Date: Thu, 28 Nov 2013 13:02:42 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR59323 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 This fixes PR59323 - we were unifying TYPE_DECLs used in different BLOCK_VARS - ultimately because they were errorneously put into the global indexed decls. Fixed by including some more kinds that, when having function context, are not indexed. This is the minimal set of kinds to fix the testcase (intentionally I refrained from adding other stuff that makes "sense" at this point). LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2013-11-28 Richard Biener PR lto/59323 * lto-streamer-out.c (tree_is_indexable): TYPE_DECLs and CONST_DECLs in function context are not indexable. * gcc.dg/lto/pr59323_0.c: New testcase. Index: gcc/lto-streamer-out.c =================================================================== --- gcc/lto-streamer-out.c (revision 205447) +++ gcc/lto-streamer-out.c (working copy) @@ -135,8 +135,10 @@ tree_is_indexable (tree t) definition. */ if (TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL) return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE); - else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t) - && !TREE_STATIC (t)) + else if (((TREE_CODE (t) == VAR_DECL && !TREE_STATIC (t)) + || TREE_CODE (t) == TYPE_DECL + || TREE_CODE (t) == CONST_DECL) + && decl_function_context (t)) return false; else if (TREE_CODE (t) == DEBUG_EXPR_DECL) return false; Index: gcc/testsuite/gcc.dg/lto/pr59323_0.c =================================================================== --- gcc/testsuite/gcc.dg/lto/pr59323_0.c (revision 0) +++ gcc/testsuite/gcc.dg/lto/pr59323_0.c (revision 0) @@ -0,0 +1,37 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -O2 -g -flto } } } */ +/* { dg-extra-ld-options { -r -nostdlib } } */ + +extern void bar(void); + +int main(int argc, char **argv) +{ + int i; + + if (argc == 1) { + enum { X }; + + bar(); + + { + enum { X }; + + asm goto ("" : : : : lab); +lab: + ; + } + } + + { + enum { X }; + + int foo(void) + { + return argv[0][0]; + } + + i = foo(); + } + + return i; +}