This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C] Always use TRANSLATION_UNIT_DECL as context
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;
}
Richard.