Commit 47a1ae3c by Jan Hubicka Committed by Jan Hubicka

re PR middle-end/51663 (Desirable/undesirable elimination of unused variables &…

re PR middle-end/51663 (Desirable/undesirable elimination of unused variables & functions at -O0, -O0 -flto and -O0 -fwhole-program)

	PR lto/51663
	* varpool.c (varpool_finalize_decl): Handle toplevel_reorder here.
	(decide_is_variable_needed): Do not handle toplevel reorder here.
	* cgraph.h (varpool_can_remove_if_no_refs): Likewise.
	* ipa.c (cgraph_remove_unreachable_nodes): Remove unreachable vars
	even at -O0.

From-SVN: r185777
parent e24e08d4
2012-03-24 Jan Hubicka <jh@suse.cz>
PR lto/51663
* varpool.c (varpool_finalize_decl): Handle toplevel_reorder here.
(decide_is_variable_needed): Do not handle toplevel reorder here.
* cgraph.h (varpool_can_remove_if_no_refs): Likewise.
* ipa.c (cgraph_remove_unreachable_nodes): Remove unreachable vars
even at -O0.
2012-03-24 Eric Botcazou <ebotcazou@adacore.com>
* expr.c (optimize_bitfield_assignment_op) <BIT_IOR_EXPR>: Use str_mode
......
......@@ -947,8 +947,6 @@ static inline bool
varpool_can_remove_if_no_refs (struct varpool_node *node)
{
return (!node->force_output && !node->used_from_other_partition
&& (flag_toplevel_reorder || DECL_COMDAT (node->decl)
|| DECL_ARTIFICIAL (node->decl))
&& (DECL_COMDAT (node->decl) || !node->externally_visible));
}
......
......@@ -419,11 +419,6 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
if (file)
fprintf (file, "\n");
/* We must release unused extern inlines or sanity checking will fail. Rest of transformations
are undesirable at -O0 since we do not want to remove anything. */
if (!optimize)
return changed;
if (file)
fprintf (file, "Reclaiming variables:");
for (vnode = varpool_nodes; vnode; vnode = vnext)
......@@ -463,6 +458,10 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
if (file)
fprintf (file, "\n");
/* Rest of transformations are undesirable at -O0. */
if (!optimize)
return changed;
#ifdef ENABLE_CHECKING
verify_cgraph ();
#endif
......
......@@ -334,10 +334,6 @@ decide_is_variable_needed (struct varpool_node *node, tree decl)
&& !DECL_EXTERNAL (decl))
return true;
/* When not reordering top level variables, we have to assume that
we are going to keep everything. */
if (!flag_toplevel_reorder)
return true;
return false;
}
......@@ -405,7 +401,11 @@ varpool_finalize_decl (tree decl)
if (node->needed)
varpool_enqueue_needed_node (node);
node->finalized = true;
if (TREE_THIS_VOLATILE (decl) || DECL_PRESERVE_P (decl))
if (TREE_THIS_VOLATILE (decl) || DECL_PRESERVE_P (decl)
/* Traditionally we do not eliminate static variables when not
optimizing and when not doing toplevel reoder. */
|| (!flag_toplevel_reorder && !DECL_COMDAT (node->decl)
&& !DECL_ARTIFICIAL (node->decl)))
node->force_output = true;
if (decide_is_variable_needed (node, decl))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment