From patchwork Mon Sep 27 09:25:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 65823 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 636C3B70E6 for ; Mon, 27 Sep 2010 19:25:59 +1000 (EST) Received: (qmail 4969 invoked by alias); 27 Sep 2010 09:25:54 -0000 Received: (qmail 4902 invoked by uid 22791); 27 Sep 2010 09:25:51 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Sep 2010 09:25:46 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 9A3C09F95B; Mon, 27 Sep 2010 11:25:43 +0200 (CEST) Date: Mon, 27 Sep 2010 11:25:43 +0200 (CEST) From: Richard Guenther To: Jie Zhang Cc: gcc-patches@gcc.gnu.org, "Joseph S. Myers" Subject: Re: [PATCH][C] Always use TRANSLATION_UNIT_DECL as context In-Reply-To: <4CA0608C.3090606@codesourcery.com> Message-ID: References: <4C9DE292.7040403@codesourcery.com> <4CA0608C.3090606@codesourcery.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) 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 On Mon, 27 Sep 2010, Jie Zhang wrote: > On 09/27/2010 04:49 PM, Richard Guenther wrote: > > On Sat, 25 Sep 2010, Jie Zhang wrote: > > > > > On 09/17/2010 08:18 PM, Richard Guenther wrote: > > > > * c-decl.c (pop_scope): Always set file-scope DECL_CONTEXT. > > > > > > This change causes regressions on arm-none-eabi: > > > > > > FAIL: gcc.c-torture/execute/builtins/abs-1.c compilation, -O2 -flto > > > UNRESOLVED: gcc.c-torture/execute/builtins/abs-1.c execution, -O2 -flto > > > > > > The compiler error messages are: > > > > > > testsuite/gcc.c-torture/execute/builtins/abs-1.c:22:1: sorry, > > > unimplemented: > > > gimple bytecode streams do not support machine specific builtin functions > > > on > > > this target > > > testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c:22:1: sorry, > > > unimplemented: gimple bytecode streams do not support machine specific > > > builtin > > > functions on this target > > > testsuite/gcc.c-torture/execute/builtins/lib/main.c:13:1: sorry, > > > unimplemented: gimple bytecode streams do not support machine specific > > > builtin > > > functions on this target > > > compiler exited with status 1 > > > > > > I did some investigation, but don't know how to fix it. > > > > > > The above change makes GCC always set file-scope DECL_CONTEXT. So when > > > come to > > > > > > static void > > > lto_output_ts_decl_minimal_tree_pointers (struct output_block *ob, tree > > > expr, > > > bool ref_p) > > > { > > > lto_output_tree_or_ref (ob, DECL_NAME (expr), ref_p); > > > lto_output_tree_or_ref (ob, DECL_CONTEXT (expr), ref_p); > > > lto_output_location (ob, DECL_SOURCE_LOCATION (expr)); > > > } > > > > > > with EXPR being a file scope function, DECL_CONEXT (expr) is the > > > translation > > > unit which contains the function. Then > > > > > > lto_output_tree_or_ref (ob, DECL_CONTEXT (expr), ref_p); > > > > > > writes out the whole translation unit including all the builtin functions. > > > Finally, in lto_output_builtin_tree, a "sorry" is called with the above > > > error > > > message since ARM target does not have targetm.builtin_decl. > > > > > > I don't know how to fix this. Defining targetm.builtin_decl for ARM should > > > fix > > > it. But I'm not sure if we really want to output all builtins for each > > > translation unit. This regression should exist for all targets which don't > > > provide targetm.builtin_decl. > > > > Yes, this writes all declarations in the TRANSLATION_UNIT_DECLs BLOCK > > tree. Does the following fix it? > > > > Index: tree.c > > =================================================================== > > --- tree.c (revision 164590) > > +++ tree.c (working copy) > > @@ -4585,6 +4690,8 @@ free_lang_data_in_decl (tree decl) > > nesting beyond this point. */ > > DECL_CONTEXT (decl) = NULL_TREE; > > } > > + else if (TREE_CODE (decl) == TRANSLATION_UNIT_DECL) > > + DECL_INITIAL (decl) = NULL_TREE; > > } > > > Not yet. This change causes an ICE. Ick ... so I guess we should instead try to not push builtins to the global scope. Like with Joseph might have an idea here (I also see external_scope being used, but I'm not sure what functions actually end up in that). Does the above help? Thanks, Richard. Index: c-decl.c =================================================================== --- c-decl.c (revision 164591) +++ c-decl.c (working copy) @@ -1142,6 +1142,10 @@ pop_scope (void) "inline function %q+D declared but never defined", p); DECL_EXTERNAL (p) = 1; } + else if (TREE_CODE (p) == FUNCTION_DECL + && DECL_BUILT_IN (p)) + /* Do not put builtin functions into the outermost BLOCK. */ + continue; goto common_symbol;