Mercurial > hg > CbC > CbC_gcc
diff gcc/ipa-cp.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
line wrap: on
line diff
--- a/gcc/ipa-cp.c Fri Feb 12 23:41:23 2010 +0900 +++ b/gcc/ipa-cp.c Mon May 24 12:47:05 2010 +0900 @@ -1,5 +1,6 @@ /* Interprocedural constant propagation - Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. Contributed by Razya Ladelsky <RAZYA@il.ibm.com> This file is part of GCC. @@ -130,6 +131,7 @@ #include "flags.h" #include "timevar.h" #include "diagnostic.h" +#include "tree-pretty-print.h" #include "tree-dump.h" #include "tree-inline.h" #include "fibheap.h" @@ -182,6 +184,7 @@ /* Unreachable nodes should have been eliminated before ipcp. */ gcc_assert (node->needed || node->reachable); + node->local.versionable = tree_versionable_function_p (node->decl); ipa_initialize_node_params (node); ipa_detect_param_modifications (node); } @@ -226,10 +229,14 @@ if (lat1->type != lat2->type) return false; - if (operand_equal_p (lat1->constant, lat2->constant, 0)) - return true; - - return false; + if (TREE_CODE (lat1->constant) == ADDR_EXPR + && TREE_CODE (lat2->constant) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (lat1->constant, 0)) == CONST_DECL + && TREE_CODE (TREE_OPERAND (lat2->constant, 0)) == CONST_DECL) + return operand_equal_p (DECL_INITIAL (TREE_OPERAND (lat1->constant, 0)), + DECL_INITIAL (TREE_OPERAND (lat2->constant, 0)), 0); + else + return operand_equal_p (lat1->constant, lat2->constant, 0); } /* Compute Meet arithmetics: @@ -385,8 +392,16 @@ fprintf (f, " param [%d]: ", i); if (lat->type == IPA_CONST_VALUE) { + tree cst = lat->constant; fprintf (f, "type is CONST "); - print_generic_expr (f, lat->constant, 0); + print_generic_expr (f, cst, 0); + if (TREE_CODE (cst) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (cst, 0)) == CONST_DECL) + { + fprintf (f, " -> "); + print_generic_expr (f, DECL_INITIAL (TREE_OPERAND (cst, 0)), + 0); + } fprintf (f, "\n"); } else if (lat->type == IPA_TOP) @@ -402,35 +417,21 @@ static bool ipcp_versionable_function_p (struct cgraph_node *node) { - tree decl = node->decl; - basic_block bb; + struct cgraph_edge *edge; /* There are a number of generic reasons functions cannot be versioned. */ - if (!tree_versionable_function_p (decl)) - return false; - - /* Removing arguments doesn't work if the function takes varargs. */ - if (DECL_STRUCT_FUNCTION (decl)->stdarg) + if (!node->local.versionable) return false; - /* Removing arguments doesn't work if we use __builtin_apply_args. */ - FOR_EACH_BB_FN (bb, DECL_STRUCT_FUNCTION (decl)) + /* Removing arguments doesn't work if the function takes varargs + or use __builtin_apply_args. */ + for (edge = node->callees; edge; edge = edge->next_callee) { - gimple_stmt_iterator gsi; - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - { - const_gimple stmt = gsi_stmt (gsi); - tree t; - - if (!is_gimple_call (stmt)) - continue; - t = gimple_call_fndecl (stmt); - if (t == NULL_TREE) - continue; - if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (t) == BUILT_IN_APPLY_ARGS) - return false; - } + tree t = edge->callee->decl; + if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL + && (DECL_FUNCTION_CODE (t) == BUILT_IN_APPLY_ARGS + || DECL_FUNCTION_CODE (t) == BUILT_IN_VA_START)) + return false; } return true; @@ -614,7 +615,6 @@ ipcp_init_stage (void) { struct cgraph_node *node; - struct cgraph_edge *cs; for (node = cgraph_nodes; node; node = node->next) if (node->analyzed) @@ -623,26 +623,10 @@ { if (!node->analyzed) continue; + + ipa_analyze_params_uses (node); /* building jump functions */ - for (cs = node->callees; cs; cs = cs->next_callee) - { - /* We do not need to bother analyzing calls to unknown - functions unless they may become known during lto/whopr. */ - if (!cs->callee->analyzed && !flag_lto && !flag_whopr) - continue; - ipa_count_arguments (cs); - if (ipa_get_cs_argument_count (IPA_EDGE_REF (cs)) - != ipa_get_param_count (IPA_NODE_REF (cs->callee))) - { - /* Handle cases of functions with - a variable number of parameters. */ - ipa_set_called_with_variable_arg (IPA_NODE_REF (cs->callee)); - if (flag_indirect_inlining) - ipa_compute_jump_functions (cs); - } - else - ipa_compute_jump_functions (cs); - } + ipa_compute_jump_functions (node); } } @@ -924,12 +908,9 @@ for (i = 0; i < count; i++) { struct ipcp_lattice *lat = ipcp_get_lattice (info, i); - tree parm_tree = ipa_get_param (info, i); /* We can proactively remove obviously unused arguments. */ - if (is_gimple_reg (parm_tree) - && !gimple_default_def (DECL_STRUCT_FUNCTION (orig_node->decl), - parm_tree)) + if (!ipa_is_param_used (info, i)) { bitmap_set_bit (args_to_skip, i); continue; @@ -1002,12 +983,9 @@ for (i = 0; i < count; i++) { struct ipcp_lattice *lat = ipcp_get_lattice (info, i); - tree parm_tree = ipa_get_param (info, i); /* We can proactively remove obviously unused arguments. */ - if (is_gimple_reg (parm_tree) - && !gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), - parm_tree)) + if (!ipa_is_param_used (info, i)) removable_args++; if (lat->type == IPA_CONST_VALUE) @@ -1075,12 +1053,9 @@ for (i = 0; i < count; i++) { struct ipcp_lattice *lat = ipcp_get_lattice (info, i); - tree parm_tree = ipa_get_param (info, i); if (ipcp_lat_is_insertable (lat) /* Do not count obviously unused arguments. */ - && (!is_gimple_reg (parm_tree) - || gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), - parm_tree))) + && ipa_is_param_used (info, i)) const_param++; } return const_param; @@ -1184,9 +1159,7 @@ parm_tree = ipa_get_param (info, i); /* We can proactively remove obviously unused arguments. */ - if (is_gimple_reg (parm_tree) - && !gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), - parm_tree)) + if (!ipa_is_param_used (info, i)) { bitmap_set_bit (args_to_skip, i); continue; @@ -1276,7 +1249,7 @@ ipcp_print_profile_data (dump_file); } /* Free all IPCP structures. */ - free_all_ipa_structures_after_ipa_cp (); + ipa_free_all_structures_after_ipa_cp (); if (dump_file) fprintf (dump_file, "\nIPA constant propagation end\n"); return 0; @@ -1298,7 +1271,8 @@ /* Write ipcp summary for nodes in SET. */ static void -ipcp_write_summary (cgraph_node_set set) +ipcp_write_summary (cgraph_node_set set, + varpool_node_set vset ATTRIBUTE_UNUSED) { ipa_prop_write_jump_functions (set); } @@ -1333,13 +1307,14 @@ 0, /* properties_destroyed */ 0, /* todo_flags_start */ TODO_dump_cgraph | TODO_dump_func | - TODO_remove_functions /* todo_flags_finish */ + TODO_remove_functions | TODO_ggc_collect /* todo_flags_finish */ }, ipcp_generate_summary, /* generate_summary */ ipcp_write_summary, /* write_summary */ ipcp_read_summary, /* read_summary */ - NULL, /* function_read_summary */ - lto_ipa_fixup_call_notes, /* stmt_fixup */ + NULL, /* write_optimization_summary */ + NULL, /* read_optimization_summary */ + NULL, /* stmt_fixup */ 0, /* TODOs */ NULL, /* function_transform */ NULL, /* variable_transform */