diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-10 19:33:37 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-10 19:33:37 +0000 |
commit | 930cff673cdaa5371507abe493f9188c81d695fe (patch) | |
tree | 34602e6c1f37225bd018fc35fc4b5af53b796857 /gcc/ipa.c | |
parent | 2f36442ddace49c11b3666e4a2c4132044970d3c (diff) | |
download | gcc-930cff673cdaa5371507abe493f9188c81d695fe.tar.gz |
PR c/43288
* ipa.c (function_and_variable_visibility) Normalize COMMON bits.
* varasm.c (get_variable_section): Don't do that here...
(make_decl_rtl): ... and here.
(do_assemble_alias): Produce decl RTL.
(assemble_alias): Likewise.
* gcc.dg/compile/pr43288.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157366 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa.c')
-rw-r--r-- | gcc/ipa.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/gcc/ipa.c b/gcc/ipa.c index 63de1d99d44..f81d41a4a28 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -407,12 +407,38 @@ function_and_variable_visibility (bool whole_program) && !DECL_EXTERNAL (node->decl) && !node->local.externally_visible); } + for (vnode = varpool_nodes; vnode; vnode = vnode->next) + { + /* weak flag makes no sense on local variables. */ + gcc_assert (!DECL_WEAK (vnode->decl) + || TREE_PUBLIC (vnode->decl) || DECL_EXTERNAL (vnode->decl)); + /* In several cases declarations can not be common: + + - when declaration has initializer + - when it is in weak + - when it has specific section + - when it resides in non-generic address space. + - if declaration is local, it will get into .local common section + so common flag is not needed. Frontends still produce these in + certain cases, such as for: + + static int a __attribute__ ((common)) + + Canonicalize things here and clear the redundant flag. */ + if (DECL_COMMON (vnode->decl) + && (!(TREE_PUBLIC (vnode->decl) || DECL_EXTERNAL (vnode->decl)) + || (DECL_INITIAL (vnode->decl) + && DECL_INITIAL (vnode->decl) != error_mark_node) + || DECL_WEAK (vnode->decl) + || DECL_SECTION_NAME (vnode->decl) != NULL + || ! (ADDR_SPACE_GENERIC_P + (TYPE_ADDR_SPACE (TREE_TYPE (vnode->decl)))))) + DECL_COMMON (vnode->decl) = 0; + } for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) { if (!vnode->finalized) continue; - gcc_assert ((!DECL_WEAK (vnode->decl) && !DECL_COMMON (vnode->decl)) - || TREE_PUBLIC (vnode->decl) || DECL_EXTERNAL (vnode->decl)); if (vnode->needed && (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl)) && (!whole_program |