aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-08-21 11:46:15 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-08-21 09:46:15 +0000
commit508e475706c3560a86b08446e1bb764773b93ed9 (patch)
treedd592015baf43a7ac0105edb4a35dc0cecd6d50f /gcc/cgraphunit.c
parentf1395d4a6e0ea98b1fa3b72d40f02fcba9801500 (diff)
downloadgcc-508e475706c3560a86b08446e1bb764773b93ed9.zip
gcc-508e475706c3560a86b08446e1bb764773b93ed9.tar.gz
gcc-508e475706c3560a86b08446e1bb764773b93ed9.tar.bz2
re PR middle-end/45307 (Stores expanding to no RTL not removed by tree optimizers, Empty ctors/dtors not eliminated)
PR c++/45307 PR c++/17736 * cgraph.h (cgraph_only_called_directly_p, cgraph_can_remove_if_no_direct_calls_and_refs_p): Handle static cdtors. * cgraphunit.c (cgraph_decide_is_function_needed): Static cdtors are not needed. (cgraph_finalize_function): Static cdtors are reachable. (cgraph_mark_functions_to_output): Use cgraph_only_called_directly_p. * gcc.dg/ipa/ctor-empty-1.c: Add testcase. * g++.dg/tree-ssa/empty-2.C: Check that constructor got optimized out. From-SVN: r163439
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r--gcc/cgraphunit.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 4ef63a2..57b7a8d 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -367,11 +367,6 @@ cgraph_decide_is_function_needed (struct cgraph_node *node, tree decl)
&& !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
return true;
- /* Constructors and destructors are reachable from the runtime by
- some mechanism. */
- if (DECL_STATIC_CONSTRUCTOR (decl) || DECL_STATIC_DESTRUCTOR (decl))
- return true;
-
return false;
}
@@ -532,7 +527,9 @@ cgraph_finalize_function (tree decl, bool nested)
/* Since we reclaim unreachable nodes at the end of every language
level unit, we need to be conservative about possible entry points
there. */
- if ((TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl)))
+ if ((TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
+ || DECL_STATIC_CONSTRUCTOR (decl)
+ || DECL_STATIC_DESTRUCTOR (decl))
cgraph_mark_reachable_node (node);
/* If we've not yet emitted decl, tell the debug info about it. */
@@ -1219,8 +1216,7 @@ cgraph_mark_functions_to_output (void)
outside the current compilation unit. */
if (node->analyzed
&& !node->global.inlined_to
- && (node->needed || node->reachable_from_other_partition
- || node->address_taken
+ && (!cgraph_only_called_directly_p (node)
|| (e && node->reachable))
&& !TREE_ASM_WRITTEN (decl)
&& !DECL_EXTERNAL (decl))