From: rguenth Date: Thu, 15 Dec 2011 09:44:11 +0000 (+0000) Subject: 2012-12-15 Richard Guenther X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=c75a2739c2dd84336557e95cf655eceb163fc341 2012-12-15 Richard Guenther Revert PR lto/48437 * lto-streamer-out.c (tree_is_indexable): Exclude block-local extern declarations. PR lto/48508 PR lto/48437 * tree-streamer-out.c (streamer_write_chain): Stream DECL_EXTERNAL VAR_DECLs and FUNCTION_DECLs locally. * g++.dg/lto/pr48508-1_0.C: New testcase. * g++.dg/lto/pr48508-1_1.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182358 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6f6172ebc98..5dfad7bdb3f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2012-12-15 Richard Guenther + + Revert + PR lto/48437 + * lto-streamer-out.c (tree_is_indexable): Exclude block-local + extern declarations. + + PR lto/48508 + PR lto/48437 + * tree-streamer-out.c (streamer_write_chain): Stream DECL_EXTERNAL + VAR_DECLs and FUNCTION_DECLs locally. + 2011-12-14 Richard Henderson * config/arm/arm.md (*addsi3_compare0_scratch): Set predicable. diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 9593134fb02..6c1169a3ec6 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -129,16 +129,6 @@ tree_is_indexable (tree t) else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t) && !TREE_STATIC (t)) return false; - /* If this is a decl generated for block local externs for - debug info generation, stream it unshared alongside BLOCK_VARS. */ - else if (VAR_OR_FUNCTION_DECL_P (t) - /* ??? The following tests are a literal match on what - c-decl.c:pop_scope does. */ - && TREE_PUBLIC (t) - && DECL_EXTERNAL (t) - && DECL_CONTEXT (t) - && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL) - return false; /* Variably modified types need to be streamed alongside function bodies because they can refer to local entities. Together with them we have to localize their members as well. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50f17867d52..66880f0e0a7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-12-15 Richard Guenther + + PR lto/48508 + * g++.dg/lto/pr48508-1_0.C: New testcase. + * g++.dg/lto/pr48508-1_1.C: Likewise. + 2011-12-14 Jason Merrill PR c++/51554 diff --git a/gcc/testsuite/g++.dg/lto/pr48508-1_0.C b/gcc/testsuite/g++.dg/lto/pr48508-1_0.C new file mode 100644 index 00000000000..6faee75b155 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr48508-1_0.C @@ -0,0 +1,7 @@ +// { dg-lto-do link } +// { dg-lto-options { { -g -O2 -flto -flto-partition=none } } } + +void __attribute__((externally_visible)) +foo (int i) +{ +} diff --git a/gcc/testsuite/g++.dg/lto/pr48508-1_1.C b/gcc/testsuite/g++.dg/lto/pr48508-1_1.C new file mode 100644 index 00000000000..5cda1925bf5 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr48508-1_1.C @@ -0,0 +1,10 @@ +static void +bar (void) +{ + extern void foo (int); + foo (0); +} +int main() +{ + bar (); +} diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c index fea15ff1137..d90ee803a13 100644 --- a/gcc/tree-streamer-out.c +++ b/gcc/tree-streamer-out.c @@ -405,7 +405,13 @@ streamer_write_chain (struct output_block *ob, tree t, bool ref_p) saved_chain = TREE_CHAIN (t); TREE_CHAIN (t) = NULL_TREE; - stream_write_tree (ob, t, ref_p); + /* We avoid outputting external vars or functions by reference + to the global decls section as we do not want to have them + enter decl merging. This is, of course, only for the call + for streaming BLOCK_VARS, but other callers are safe. */ + stream_write_tree (ob, t, + ref_p && !(VAR_OR_FUNCTION_DECL_P (t) + && DECL_EXTERNAL (t))); TREE_CHAIN (t) = saved_chain; t = TREE_CHAIN (t);