From 4189e6771feda58eeb5859eb78adaeb1ce9729e1 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Tue, 30 Jun 2009 17:26:32 +0000 Subject: * cgraphunit.c (cgraph_finalize_compilation_unit): Call finalize_size_functions before further processing. * stor-layout.c: Include cgraph.h, tree-inline.h and tree-dump.h. (variable_size): Call self_referential_size on size expressions that contain a PLACEHOLDER_EXPR. (size_functions): New static variable. (copy_self_referential_tree_r): New static function. (self_referential_size): Likewise. (finalize_size_functions): New global function. * tree.c: Include tree-inline.h. (push_without_duplicates): New static function. (find_placeholder_in_expr): New global function. (substitute_in_expr) : Return the replacement object on equality. : Likewise. : If the replacement object is a constant, try to inline the call in the expression. * tree.h (finalize_size_functions): Declare. (find_placeholder_in_expr): Likewise. (FIND_PLACEHOLDER_IN_EXPR): New macro. (substitute_placeholder_in_expr): Update comment. * tree-inline.c (remap_decl): Do not unshare trees if do_not_unshare is true. (copy_tree_body_r): Likewise. (copy_tree_body): New static function. (maybe_inline_call_in_expr): New global function. * tree-inline.h (struct copy_body_data): Add do_not_unshare field. (maybe_inline_call_in_expr): Declare. * Makefile.in (tree.o): Depend on TREE_INLINE_H. (stor-layout.o): Depend on CGRAPH_H, TREE_INLINE_H, TREE_DUMP_H and GIMPLE_H. ada/ * gcc-interface/decl.c: Include tree-inline.h. (annotate_value) : Try to inline the call in the expression. * gcc-interface/utils.c (max_size) : Likewise. * gcc-interface/utils2.c: Include tree-inline. (known_alignment) : Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149112 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b97b9b2b772..648e30b47b3 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -287,7 +287,10 @@ remap_decl (tree decl, copy_body_data *id) return t; } - return unshare_expr (*n); + if (id->do_not_unshare) + return *n; + else + return unshare_expr (*n); } static tree @@ -997,7 +1000,10 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) but we absolutely rely on that. As fold_indirect_ref does other useful transformations, try that first, though. */ tree type = TREE_TYPE (TREE_TYPE (*n)); - new_tree = unshare_expr (*n); + if (id->do_not_unshare) + new_tree = *n; + else + new_tree = unshare_expr (*n); old = *tp; *tp = gimple_fold_indirect_ref (new_tree); if (! *tp) @@ -1993,6 +1999,20 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, return new_fndecl; } +/* Make a copy of the body of SRC_FN so that it can be inserted inline in + another function. */ + +static tree +copy_tree_body (copy_body_data *id) +{ + tree fndecl = id->src_fn; + tree body = DECL_SAVED_TREE (fndecl); + + walk_tree (&body, copy_tree_body_r, id, NULL); + + return body; +} + static tree copy_body (copy_body_data *id, gcov_type count, int frequency, basic_block entry_block_map, basic_block exit_block_map) @@ -4605,6 +4625,60 @@ tree_function_versioning (tree old_decl, tree new_decl, return; } +/* EXP is CALL_EXPR present in a GENERIC expression tree. Try to integrate + the callee and return the inlined body on success. */ + +tree +maybe_inline_call_in_expr (tree exp) +{ + tree fn = get_callee_fndecl (exp); + + /* We can only try to inline "const" functions. */ + if (fn && TREE_READONLY (fn) && DECL_SAVED_TREE (fn)) + { + struct pointer_map_t *decl_map = pointer_map_create (); + call_expr_arg_iterator iter; + copy_body_data id; + tree param, arg, t; + + /* Remap the parameters. */ + for (param = DECL_ARGUMENTS (fn), arg = first_call_expr_arg (exp, &iter); + param; + param = TREE_CHAIN (param), arg = next_call_expr_arg (&iter)) + *pointer_map_insert (decl_map, param) = arg; + + memset (&id, 0, sizeof (id)); + id.src_fn = fn; + id.dst_fn = current_function_decl; + id.src_cfun = DECL_STRUCT_FUNCTION (fn); + id.decl_map = decl_map; + + id.copy_decl = copy_decl_no_change; + id.transform_call_graph_edges = CB_CGE_DUPLICATE; + id.transform_new_cfg = false; + id.transform_return_to_modify = true; + id.transform_lang_insert_block = false; + + /* Make sure not to unshare trees behind the front-end's back + since front-end specific mechanisms may rely on sharing. */ + id.regimplify = false; + id.do_not_unshare = true; + + /* We're not inside any EH region. */ + id.eh_region = -1; + + t = copy_tree_body (&id); + pointer_map_destroy (decl_map); + + /* We can only return something suitable for use in a GENERIC + expression tree. */ + if (TREE_CODE (t) == MODIFY_EXPR) + return TREE_OPERAND (t, 1); + } + + return NULL_TREE; +} + /* Duplicate a type, fields and all. */ tree -- cgit v1.2.1 From 389dd41bd043170e7dc7660304f14a5f16af3562 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 16 Jul 2009 22:29:52 +0000 Subject: =?UTF-8?q?2009-07-17=20=20Aldy=20Hernandez=20=20=20=09=20=20=20=20Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR 40435 * tree-complex.c, tree-loop-distribution.c, tree.c, tree.h, builtins.c, fold-const.c, omp-low.c, cgraphunit.c, tree-ssa-ccp.c, tree-ssa-dom.c, gimple-low.c, expr.c, tree-ssa-ifcombine.c, c-decl.c, stor-layout.c, tree-if-conv.c, c-typeck.c, gimplify.c, calls.c, tree-sra.c, tree-mudflap.c, tree-ssa-copy.c, tree-ssa-forwprop.c, c-convert.c, c-omp.c, varasm.c, tree-inline.c, c-common.c, c-common.h, gimple.c, tree-switch-conversion.c, gimple.h, tree-cfg.c, c-parser.c, convert.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. objc/ * objc-act.c: Add location argument to all calls to build_fold_addr_expr. testsuite/ * gcc.dg/pr36902.c: Add column info. * g++.dg/gcov/gcov-2.C: Change count for definition. cp/ * typeck.c, init.c, class.c, method.c, rtti.c, except.c, error.c, tree.c, cp-gimplify.c, cxx-pretty-print.c, pt.c, semantics.c, call.c, cvt.c, mangle.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. fortran/ * trans-expr.c, trans-array.c, trans-openmp.c, trans-stmt.c, trans.c, trans-io.c, trans-decl.c, trans-intrinsic.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149722 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 648e30b47b3..ed947da759a 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -778,7 +778,8 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) { if (TREE_CODE (new_tree) == ADDR_EXPR) { - *tp = fold_indirect_ref_1 (type, new_tree); + *tp = fold_indirect_ref_1 (EXPR_LOCATION (new_tree), + type, new_tree); /* ??? We should either assert here or build a VIEW_CONVERT_EXPR instead of blindly leaking incompatible types to our IL. */ @@ -1010,7 +1011,8 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) { if (TREE_CODE (new_tree) == ADDR_EXPR) { - *tp = fold_indirect_ref_1 (type, new_tree); + *tp = fold_indirect_ref_1 (EXPR_LOCATION (new_tree), + type, new_tree); /* ??? We should either assert here or build a VIEW_CONVERT_EXPR instead of blindly leaking incompatible types to our IL. */ -- cgit v1.2.1 From bfec3452cfb96a7546809ee1af3fffb9eba9d658 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 17 Jul 2009 15:49:34 +0000 Subject: 2009-07-17 Richard Guenther PR c/40401 * tree-pass.h (pass_diagnose_omp_blocks): Declare. (pass_warn_unused_result): Likewise. (TODO_set_props): Remove. * omp-low.c (diagnose_omp_structured_block_errors): Change to run as a pass. (pass_diagnose_omp_blocks): Define. * c-decl.c (pop_file_scope): Do not finalize the CU here. (c_gimple_diagnostics_recursively): Remove. (finish_function): Do not call it. (c_write_global_declarations): Continue after errors. Finalize the CU here. * c-gimplify.c (c_genericize): Do not gimplify here. * c-common.c (c_warn_unused_result): Move ... * tree-cfg.c (do_warn_unused_result): ... here. (run_warn_unused_result): New function. (gate_warn_unused_result): New function. (pass_warn_unused_result): New pass. * c-common.h (c_warn_unused_result): Remove. * flags.h (flag_warn_unused_result): Declare. * c-opts.c (c_common_init_options): Enable flag_warn_unused_result. * opts.c (flag_warn_unused_result): Initialize to false. * toplev.c (compile_file): Add comment. * omp-low.c (create_omp_child_function): Do not register the function with the frontend. (diagnose_omp_structured_block_errors): Prepare to be called as optimization pass. (gate_diagnose_omp_blocks): New function. (pass_diagnose_omp_blocks): New pass. * cgraph.h (cgraph_optimize): Remove. (cgraph_analyze_function): Likewise. * cgraph.c (cgraph_add_new_function): Gimplify C++ thunks. * cgraphunit.c (cgraph_lower_function): Lower nested functions before their parents here. (cgraph_finalize_function): Not here. (cgraph_analyze_function): Gimplify functions here. (cgraph_finalize_compilation_unit): Continue after errors. Optimize the callgraph from here. (cgraph_optimize): Make static. * langhooks.c (write_global_declarations): Finalize the CU. * gimplify.c (gimplify_asm_expr): Do not emit ASMs with errors. (gimplify_function_tree): Assert we gimplify only once. Set PROP_gimple_any property. * tree-nested.c (gimplify_all_functions): New function. (lower_nested_functions): Gimplify all nested functions. * gimple.h (diagnose_omp_structured_block_errors): Remove. * passes.c (init_optimization_passes): Add pass_warn_unused_result and pass_diagnose_omp_blocks after gimplification. Do not set TODO_set_props on all_lowering_passes. (execute_one_pass): Do not handle TODO_set_props. * Makefile.in (cgraphunit.o): Add $(TREE_DUMP_H) dependency. (gimplify.o): Add tree-pass.h dependency. * tree-inline.c (copy_statement_list): Properly copy STATEMENT_LIST. (copy_tree_body_r): Properly handle TARGET_EXPR like SAVE_EXPR. (unsave_r): Likewise. * c-omp.c (c_finish_omp_atomic): Set DECL_CONTEXT on the temporary variable. cp/ * decl.c (finish_function): Do not emit unused result warnings from here. * cp-objcp-common.h (LANG_HOOKS_POST_GIMPLIFY_PASS): Use c_warn_unused_result_pass. * semantics.c (expand_or_defer_fn): Adjust assertion about IL status. * optimize.c (clone_body): Clone in GENERIC. (maybe_clone_body): Do not clear DECL_SAVED_TREE. * decl2.c (cp_write_global_declarations): Fix body test. Do not call cgraph_optimize. * Make-lang.in (optimize.o): Add tree-iterator.h dependency. * method.c (use_thunk): Register thunk with cgraph_finalize_function. * error.c (function_category): Guard access of DECL_LANG_SPECIFIC. java/ * java-gimplify.c (java_genericize): Do not gimplify here. But replace all local references. (java_gimplify_expr): Do not replace local references here. (java_gimplify_modify_expr): Likewise. * jcf-parse.c (java_parse_file): Do not finalize the CU or optimize the cgraph here. * decl.c (java_replace_reference): Make static. (java_replace_references): New function. (end_java_method): Clear base_decl_map. * java-tree.h (java_replace_references): Declare. (java_replace_reference): Remove. ada/ * utils.c (end_subprog_body): Revert to pre-tuples state. Remove unused parameter. (gnat_gimplify_function): Do not gimplify here. Fold into its only caller and remove. (gnat_builtin_function): Adjust for end_subprog_body signature change. (gnat_write_global_declarations): Also finalize the CU. * misc.c (gnat_parse_file): Do not finalize the CU here. * trans.c (gigi): Revert to pre-tuples state. (Subprogram_Body_to_gnu): Adjust for end_subprog_body signature change. * gigi.h (end_subprog_body): Remove unused parameter. fortran/ * f95-lang.c (gfc_be_parse_file): Do not finalize the CU here. * trans-decl.c (gfc_gimplify_function): Remove. (build_entry_thunks): Do not gimplify here. (create_main_function): Likewise. (gfc_generate_function_code): Likewise. * g++.dg/rtti/crash4.C: New testcase. * g++.dg/torture/20090706-1.C: Likewise. * gcc.dg/redecl-17.c: Likewise. * gfortran.dg/missing_optional_dummy_5.f90: Adjust pattern. * gcc.dg/declspec-9.c: Expect extra error. * gcc.dg/declspec-10.c: Likewise. * gcc.dg/declspec-11.c: Likewise. * gcc.dg/redecl-10.c: Expect extra warnings. * gcc.target/i386/pr39082-1.c: Adjust diagnostic location. * gcc.target/i386/pr39545-1.c: Likewise. * g++.dg/ext/asm3.C: Expect more errors. * g++.dg/gomp/block-1.C: Likewise. * g++.dg/gomp/block-2.C: Likewise. * g++.dg/gomp/block-3.C: Likewise. * g++.dg/gomp/block-5.C: Likewise. * g++.old-deja/g++.jason/report.C: Expect extra warnings. * g++.dg/warn/unused-result1.C: XFAIL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149750 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ed947da759a..a28f0a4cbbc 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -603,7 +603,12 @@ copy_statement_list (tree *tp) *tp = new_tree; for (; !tsi_end_p (oi); tsi_next (&oi)) - tsi_link_after (&ni, tsi_stmt (oi), TSI_NEW_STMT); + { + tree stmt = tsi_stmt (oi); + if (TREE_CODE (stmt) == STATEMENT_LIST) + copy_statement_list (&stmt); + tsi_link_after (&ni, stmt, TSI_CONTINUE_LINKING); + } } static void @@ -921,7 +926,8 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) } else if (TREE_CODE (*tp) == STATEMENT_LIST) copy_statement_list (tp); - else if (TREE_CODE (*tp) == SAVE_EXPR) + else if (TREE_CODE (*tp) == SAVE_EXPR + || TREE_CODE (*tp) == TARGET_EXPR) remap_save_expr (tp, id->decl_map, walk_subtrees); else if (TREE_CODE (*tp) == LABEL_DECL && (! DECL_CONTEXT (*tp) @@ -3919,7 +3925,8 @@ unsave_r (tree *tp, int *walk_subtrees, void *data) gcc_unreachable (); else if (TREE_CODE (*tp) == BIND_EXPR) copy_bind_expr (tp, walk_subtrees, id); - else if (TREE_CODE (*tp) == SAVE_EXPR) + else if (TREE_CODE (*tp) == SAVE_EXPR + || TREE_CODE (*tp) == TARGET_EXPR) remap_save_expr (tp, st, walk_subtrees); else { -- cgit v1.2.1 From e20422ea77c058c25764d08e3dff633157dc696f Mon Sep 17 00:00:00 2001 From: jamborm Date: Mon, 20 Jul 2009 12:15:02 +0000 Subject: 2009-07-20 Jan Hubicka Martin Jambor * cgraph.h (combined_args_to_skip): New field. * cgraph.c (cgraph_create_virtual_clone): Properly handle combined_args_to_skip and args_to_skip. * tree-inline.c (update_clone_info): New function. (tree_function_versioning): Call update_clone_info. * cgraphunit.c: (cgraph_materialize_clone): Dump materialized functions. (cgraph_materialize_all_clones): More extensive dumping, working with combined_args_to_skip rather than args_to_skip. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149808 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a28f0a4cbbc..8b5e1ffeafc 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4446,6 +4446,42 @@ delete_unreachable_blocks_update_callgraph (copy_body_data *id) return changed; } +/* Update clone info after duplication. */ + +static void +update_clone_info (copy_body_data * id) +{ + struct cgraph_node *node; + if (!id->dst_node->clones) + return; + for (node = id->dst_node->clones; node != id->dst_node;) + { + /* First update replace maps to match the new body. */ + if (node->clone.tree_map) + { + unsigned int i; + for (i = 0; i < VEC_length (ipa_replace_map_p, node->clone.tree_map); i++) + { + struct ipa_replace_map *replace_info; + replace_info = VEC_index (ipa_replace_map_p, node->clone.tree_map, i); + walk_tree (&replace_info->old_tree, copy_tree_body_r, id, NULL); + walk_tree (&replace_info->new_tree, copy_tree_body_r, id, NULL); + } + } + if (node->clones) + node = node->clones; + else if (node->next_sibling_clone) + node = node->next_sibling_clone; + else + { + while (node != id->dst_node && !node->next_sibling_clone) + node = node->clone_of; + if (node != id->dst_node) + node = node->next_sibling_clone; + } + } +} + /* Create a copy of a function's tree. OLD_DECL and NEW_DECL are FUNCTION_DECL tree nodes of the original function and the new copied function @@ -4602,6 +4638,7 @@ tree_function_versioning (tree old_decl, tree new_decl, while (VEC_length (gimple, init_stmts)) insert_init_stmt (bb, VEC_pop (gimple, init_stmts)); } + update_clone_info (&id); /* Remap the nonlocal_goto_save_area, if any. */ if (cfun->nonlocal_goto_save_area) -- cgit v1.2.1 From 567cd5189541199db944bb9a9c09b7522b872508 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 21 Jul 2009 14:51:13 +0000 Subject: PR tree-optimization/40813 * tree-inline.c (copy_bb): Regimplify RHS after last stmt, not before it. * g++.dg/opt/inline15.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149857 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 8b5e1ffeafc..3b7b666c984 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1383,8 +1383,8 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, { tree new_rhs; new_rhs = force_gimple_operand_gsi (&seq_gsi, - gimple_assign_rhs1 (stmt), - true, NULL, true, GSI_SAME_STMT); + gimple_assign_rhs1 (stmt), + true, NULL, false, GSI_NEW_STMT); gimple_assign_set_rhs1 (stmt, new_rhs); id->regimplify = false; } -- cgit v1.2.1 From bdb1f0d12f7e167895579014a5dc03611c68e090 Mon Sep 17 00:00:00 2001 From: jamborm Date: Sat, 25 Jul 2009 18:09:42 +0000 Subject: 2009-07-25 Martin Jambor * doc/extend.texi (Labels as Values): Document need for noclone. (Function Attributes): Document noclone attribute. * c-common.c (c_common_attribute_table): New element for noclone. (handle_noclone_attribute): New function. Forward-declare. * tree-inline.c (tree_versionable_function_p): Check for noclone attribute. * testsuite/gcc.c-torture/execute/pr17377.c: Add noclone attribute to function y. * testsuite/gcc.dg/ipa/noclone-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150086 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3b7b666c984..605f91ef1a9 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4349,7 +4349,8 @@ copy_static_chain (tree static_chain, copy_body_data * id) bool tree_versionable_function_p (tree fndecl) { - return copy_forbidden (DECL_STRUCT_FUNCTION (fndecl), fndecl) == NULL; + return (!lookup_attribute ("noclone", DECL_ATTRIBUTES (fndecl)) + && copy_forbidden (DECL_STRUCT_FUNCTION (fndecl), fndecl) == NULL); } /* Delete all unreachable basic blocks and update callgraph. -- cgit v1.2.1 From da50fe8f588a6dc5f7ebabd347d87741f06f7120 Mon Sep 17 00:00:00 2001 From: rth Date: Thu, 30 Jul 2009 00:34:47 +0000 Subject: * cgraph.c (cgraph_set_call_stmt_including_clones): Tidy. (cgraph_create_edge_including_clones): Likewise. * tree-inline.c (copy_bb): Operate on the correct edges when updating the callgraph. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150234 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 108 +++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 605f91ef1a9..e62c5c1e792 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1496,67 +1496,69 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, callgraph edges and update or duplicate them. */ if (is_gimple_call (stmt)) { - struct cgraph_edge *edge = cgraph_edge (id->src_node, orig_stmt); + struct cgraph_edge *edge; int flags; switch (id->transform_call_graph_edges) { - case CB_CGE_DUPLICATE: - if (edge) - cgraph_clone_edge (edge, id->dst_node, stmt, - REG_BR_PROB_BASE, 1, - edge->frequency, true); - break; - - case CB_CGE_MOVE_CLONES: - cgraph_set_call_stmt_including_clones (id->dst_node, orig_stmt, stmt); - break; - - case CB_CGE_MOVE: - if (edge) - cgraph_set_call_stmt (edge, stmt); - break; - - default: - gcc_unreachable (); + case CB_CGE_DUPLICATE: + edge = cgraph_edge (id->src_node, orig_stmt); + if (edge) + edge = cgraph_clone_edge (edge, id->dst_node, stmt, + REG_BR_PROB_BASE, 1, + edge->frequency, true); + break; + + case CB_CGE_MOVE_CLONES: + cgraph_set_call_stmt_including_clones (id->dst_node, + orig_stmt, stmt); + edge = cgraph_edge (id->dst_node, stmt); + break; + + case CB_CGE_MOVE: + edge = cgraph_edge (id->dst_node, orig_stmt); + if (edge) + cgraph_set_call_stmt (edge, stmt); + break; + + default: + gcc_unreachable (); } - edge = cgraph_edge (id->src_node, orig_stmt); - /* Constant propagation on argument done during inlining - may create new direct call. Produce an edge for it. */ - if ((!edge - || (edge->indirect_call - && id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)) - && is_gimple_call (stmt) - && (fn = gimple_call_fndecl (stmt)) != NULL) - { - struct cgraph_node *dest = cgraph_node (fn); - - /* We have missing edge in the callgraph. This can happen in one case - where previous inlining turned indirect call into direct call by - constant propagating arguments. In all other cases we hit a bug - (incorrect node sharing is most common reason for missing edges. */ - gcc_assert (dest->needed || !dest->analyzed); - if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) - cgraph_create_edge_including_clones (id->dst_node, dest, stmt, - bb->count, - compute_call_stmt_bb_frequency (id->dst_node->decl, bb), - bb->loop_depth, - CIF_ORIGINALLY_INDIRECT_CALL); - else - cgraph_create_edge (id->dst_node, dest, stmt, - bb->count, CGRAPH_FREQ_BASE, - bb->loop_depth)->inline_failed - = CIF_ORIGINALLY_INDIRECT_CALL; - if (dump_file) - { - fprintf (dump_file, "Created new direct edge to %s", - cgraph_node_name (dest)); - } - } + /* Constant propagation on argument done during inlining + may create new direct call. Produce an edge for it. */ + if ((!edge + || (edge->indirect_call + && id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)) + && is_gimple_call (stmt) + && (fn = gimple_call_fndecl (stmt)) != NULL) + { + struct cgraph_node *dest = cgraph_node (fn); + + /* We have missing edge in the callgraph. This can happen + when previous inlining turned an indirect call into a + direct call by constant propagating arguments. In all + other cases we hit a bug (incorrect node sharing is the + most common reason for missing edges). */ + gcc_assert (dest->needed || !dest->analyzed); + if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) + cgraph_create_edge_including_clones + (id->dst_node, dest, stmt, bb->count, + compute_call_stmt_bb_frequency (id->dst_node->decl, bb), + bb->loop_depth, CIF_ORIGINALLY_INDIRECT_CALL); + else + cgraph_create_edge (id->dst_node, dest, stmt, + bb->count, CGRAPH_FREQ_BASE, + bb->loop_depth)->inline_failed + = CIF_ORIGINALLY_INDIRECT_CALL; + if (dump_file) + { + fprintf (dump_file, "Created new direct edge to %s", + cgraph_node_name (dest)); + } + } flags = gimple_call_flags (stmt); - if (flags & ECF_MAY_BE_ALLOCA) cfun->calls_alloca = true; if (flags & ECF_RETURNS_TWICE) -- cgit v1.2.1 From efbcb6defd4842cee3bc73eec195fe425457ea13 Mon Sep 17 00:00:00 2001 From: amacleod Date: Thu, 30 Jul 2009 18:36:30 +0000 Subject: Add source_location support to PHI arguments. 2009-07-29 Andrew MacLeod PR debug 26475 * tree-into-ssa.c (insert_phi_nodes_for, rewrite_add_phi_arguments): Set location for phi arguments. (rewrite_update_phi_arguments): Find locations for reaching defs. * tree-ssa-threadupdate.c (create_edge_and_update_destination_phis): Add location to add_phi_arg calls. * tree-loop-districbution.c (update_phis_for_loop_copy): Add locations. * tree-ssa-loop-manip.c (create_iv, add_exit_phis_edge, split_loop_exit_edge, tree_transform_and_unroll_loop): Add locations. * tree-tailcall.c (add_successor_phi_arg, eliminate_tail_call, create_tailcall_accumulator, tree_optimize_tail_calls_1): Add locations. * tree.h (struct phi_arg_d): Add location_t to PHI arguments. * tree-phinodes.c (make_phi_node): Initialize location. (resize_phi_node): Initialize location to UNKNOWN_LOCATION. (add_phi_arg): Add location parameter. (remove_phi_arg_num): Move location when moving phi argument. * omp-low.c (expand_parallel_call, expand_omp_for_static_chunk): Set location. * tree-vect-loop-manip.c (slpeel_update_phis_for_duplicate_loop, slpeel_update_phi_nodes_for_guard1, slpeel_update_phi_nodes_for_guard2, slpeel_tree_duplicate_loop_to_edge_cfg, set_prologue_iterations, vect_loop_versioning): Set locations. * tree-parloops.c (create_phi_for_local_result, transform_to_exit_first_loop, create_parallel_loop): Add locations. * gimple-pretty-print.c (dump_gimple_phi): Dump lineno's if present. * tree-vect-loop.c (get_initial_def_for_induction, vect_create_epilog_for_reduction, vect_finalize_reduction): Add locations. * tree-flow-inline.h (gimple_phi_arg_location): New. Return locus. (gimple_phi_arg_location_from_edge): New. Return locus from an edge. (gimple_phi_arg_set_location): New. Set locus. (gimple_phi_arg_has_location): New. Check for locus. (redirect_edge_var_map_location): New. Return locus from var_map. * tree-vect-data-refs.c (vect_setup_realignment): Set location. * tree-ssa-phiopt.c (conditional_replacement): Set locus when combining PHI arguments. (cond_store_replacement): Set location. * cfgexpand.c (gimple_assign_rhs_to_tree): Transfer locus if possible. * grpahite.c (add_loop_exit_phis, add_guard_exit_phis, scop_add_exit_phis_edge): Add locations. * tree-cfgcleanup.c (remove_forwarder_block, remove_forwarder_block_with_phi): Add locations. * tree-ssa-pre.c (insert_into_preds_of_block): Add locations. * tree-predcom.c (initialize_root_vars, initialize_root_vars_lm): Add locations. * tree-ssa-dce.c (forward_edge_to_pdom): Add locations. * tree-ssa.c (redirect_edge_var_map_add, ssa_redirect_edge, flush_pending_stmts): Add source location. * lambda-code.c (perfect_nestify): Maintain location stack with argument stack to preserve locations. * tree-vect-stmts.c (vectorizable_load): Add location. * tree-inline.c (copy_phis_for_bb): Copy locus. (setup_one_parameter): Add call locus to inlined parameter stmts. (initialize_inlined_parameters): Pass in call location as parameter assignment locus. (tree_function_versioning): Pass location to setup_one_parameter. * tree-ssa-phiprop.c (phiprop_insert_phi): Set locations. * tree-outof-ssa.c (struct _elim_graph): Add source_location vecs for copy and edge lists. (insert_partition_copy_on_edge, insert_value_copy_on_edge, insert_rtx_to_part_on_edge, insert_part_to_rtx_on_edge): Provide a locus parameter and override the stmt default if provided. (new_elim_graph, clear_elim_graph, delete_elim_graph, elim_graph_add_edge, elim_graph_remove_succ_edge, FOR_EACH_ELIM_GRAPH_SUCC, FOR_EACH_ELIM_GRAPH_PRED, eliminate_build, elim_forward, elim_unvisited_predecessor, elim_backward, elim_create, eliminate_phi): Add locus info in elimination graph for each edge and value copy. (insert_backedge_copies): Copy locus if present. * tree-flow.h (struct _edge_var_map): Add locus field. * tree-switch_conversions.c (fix_phi_nodes): Add locations. * tree-cfg.c (reinstall_phi_args, gimple_make_forwarder_block, add_phi_args_after_copy_edge, gimple_lv_adjust_loop_header_phi): Add locations. * ipa-struct-reorg.c (make_edge_and_fix_phis_of_dest): Add locations. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150267 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e62c5c1e792..f79ba758088 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1828,7 +1828,8 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id) new_arg = force_gimple_operand (new_arg, &stmts, true, NULL); gsi_insert_seq_on_edge_immediate (new_edge, stmts); } - add_phi_arg (new_phi, new_arg, new_edge); + add_phi_arg (new_phi, new_arg, new_edge, + gimple_phi_arg_location_from_edge (phi, old_edge)); } } } -- cgit v1.2.1 From 29f90295efc6e5f029a3cadad89f017e856b8384 Mon Sep 17 00:00:00 2001 From: dodji Date: Mon, 10 Aug 2009 07:16:08 +0000 Subject: 2009-08-10 Dodji Seketeli gcc/ChangeLog: PR c++/40866 * tree-inline.c (copy_statement_list): The resulting copy shouldn't loose the original type of the statement list. gcc/testsuite/ChangeLog: PR c++/40866 * g++.dg/expr/stmt-expr-1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150615 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f79ba758088..3b07aaa36ba 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -600,6 +600,7 @@ copy_statement_list (tree *tp) new_tree = alloc_stmt_list (); ni = tsi_start (new_tree); oi = tsi_start (*tp); + TREE_TYPE (new_tree) = TREE_TYPE (*tp); *tp = new_tree; for (; !tsi_end_p (oi); tsi_next (&oi)) -- cgit v1.2.1 From 19bcf5214614bfc4322ffbe3d93c2fbcf6c22c26 Mon Sep 17 00:00:00 2001 From: davidxl Date: Wed, 12 Aug 2009 16:51:41 +0000 Subject: Fix to PR41012 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150703 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3b07aaa36ba..97c9261b469 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4754,9 +4754,10 @@ build_duplicate_type (tree type) } /* Return whether it is safe to inline a function because it used different - target specific options or different optimization options. */ + target specific options or call site actual types mismatch parameter types. + E is the call edge to be checked. */ bool -tree_can_inline_p (tree caller, tree callee) +tree_can_inline_p (struct cgraph_edge *e) { #if 0 /* This causes a regression in SPEC in that it prevents a cold function from @@ -4785,7 +4786,25 @@ tree_can_inline_p (tree caller, tree callee) return false; } #endif + tree caller, callee; + + caller = e->caller->decl; + callee = e->callee->decl; /* Allow the backend to decide if inlining is ok. */ - return targetm.target_option.can_inline_p (caller, callee); + if (!targetm.target_option.can_inline_p (caller, callee)) + { + e->inline_failed = CIF_TARGET_OPTION_MISMATCH; + gimple_call_set_cannot_inline (e->call_stmt, true); + return false; + } + + if (!gimple_check_call_args (e->call_stmt)) + { + e->inline_failed = CIF_MISMATCHED_ARGUMENTS; + gimple_call_set_cannot_inline (e->call_stmt, true); + return false; + } + + return true; } -- cgit v1.2.1 From 9845d1202fec65574ca05d780859eb8c25489566 Mon Sep 17 00:00:00 2001 From: aoliva Date: Wed, 2 Sep 2009 02:42:21 +0000 Subject: gcc/ChangeLog: * doc/invoke.texi (-fvar-tracking-assignments): New. (-fvar-tracking-assignments-toggle): New. (-fdump-final-insns=file): Mark filename as optional. (--param min-nondebug-insn-uid): New. (-gdwarf-@{version}): Mention version 4. * opts.c (common_handle_option): Accept it. * tree-vrp.c (find_assert_locations_1): Skip debug stmts. * regrename.c (regrename_optimize): Drop last. Don't count debug insns as uses. Don't reject change because of debug insn. (do_replace): Reject DEBUG_INSN as chain starter. Take base_regno from the chain starter, and check for inexact matches in DEBUG_INSNS. (scan_rtx_reg): Accept inexact matches in DEBUG_INSNs. (build_def_use): Simplify and fix the marking of DEBUG_INSNs. * sched-ebb.c (schedule_ebbs): Skip boundary debug insns. * fwprop.c (forward_propagate_and_simplify): ...into debug insns. * doc/gimple.texi (is_gimple_debug): New. (gimple_debug_bind_p): New. (is_gimple_call, gimple_assign_cast_p): End sentence with period. * doc/install.texi (bootstrap-debug): More details. (bootstrap-debug-big, bootstrap-debug-lean): Document. (bootstrap-debug-lib): More details. (bootstrap-debug-ckovw): Update. (bootstrap-time): New. * tree-into-ssa.c (mark_def_sites): Skip debug stmts. (insert_phi_nodes_for): Insert debug stmts. (rewrite_stmt): Take iterator. Insert debug stmts. (rewrite_enter_block): Adjust. (maybe_replace_use_in_debug_stmt): New. (rewrite_update_stmt): Use it. (mark_use_interesting): Return early for debug stmts. * tree-ssa-loop-im.c (rewrite_bittest): Propagate DEFs into debug stmts before replacing stmt. (move_computations_stmt): Likewise. * ira-conflicts.c (add_copies): Skip debug insns. * regstat.c (regstat_init_n_sets_and_refs): Discount debug insns. (regstat_bb_compute_ri): Skip debug insns. * tree-ssa-threadupdate.c (redirection_block_p): Skip debug stmts. * tree-ssa-loop-manip.c (find_uses_to_rename_stmt, check_loop_closed_ssa_stmt): Skip debug stmts. * tree-tailcall.c (find_tail_calls): Likewise. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Likewise. * tree.h (MAY_HAVE_DEBUG_STMTS): New. (build_var_debug_value_stat): Declare. (build_var_debug_value): Define. (target_for_debug_bind): Declare. * reload.c (find_equiv_reg): Skip debug insns. * rtlanal.c (reg_used_between_p): Skip debug insns. (side_effects_p): Likewise. (canonicalize_condition): Likewise. * ddg.c (create_ddg_dep_from_intra_loop_link): Check that non-debug insns never depend on debug insns. (create_ddg_dep_no_link): Likewise. (add_cross_iteration_register_deps): Use ANTI_DEP for debug insns. Don't add inter-loop dependencies for debug insns. (build_intra_loop_deps): Likewise. (create_ddg): Count debug insns. * ddg.h (struct ddg::num_debug): New. (num_backargs): Pair up with previous int field. * diagnostic.c (diagnostic_report_diagnostic): Skip notes on -fcompare-debug-second. * final.c (get_attr_length_1): Skip debug insns. (rest_of_clean-state): Don't dump CFA_RESTORE_STATE. * gcc.c (invoke_as): Call compare-debug-dump-opt. (driver_self_specs): Map -fdump-final-insns to -fdump-final-insns=.. (get_local_tick): New. (compare_debug_dump_opt_spec_function): Test for . argument and compute output name. Compute temp output spec without flag name. Compute -frandom-seed. (OPT): Undef after use. * cfgloopanal.c (num_loop_insns): Skip debug insns. (average_num_loop_insns): Likewise. * params.h (MIN_NONDEBUG_INSN_UID): New. * gimple.def (GIMPLE_DEBUG): New. * ipa-reference.c (scan_stmt_for_static_refs): Skip debug stmts. * auto-inc-dec.c (merge_in_block): Skip debug insns. (merge_in_block): Fix whitespace. * toplev.c (flag_var_tracking): Update comment. (flag_var_tracking_assignments): New. (flag_var_tracking_assignments_toggle): New. (process_options): Don't open final insns dump file if we're not going to write to it. Compute defaults for var_tracking. * df-scan.c (df_insn_rescan_debug_internal): New. (df_uses_record): Handle debug insns. * haifa-sched.c (ready): Initialize n_debug. (contributes_to_priority): Skip debug insns. (dep_list_size): New. (priority): Use it. (rank_for_schedule): Likewise. Schedule debug insns as soon as they're ready. Disregard previous debug insns to make decisions. (queue_insn): Never queue debug insns. (ready_add, ready_remove_first, ready_remove): Count debug insns. (schedule_insn): Don't reject debug insns because of issue rate. (get_ebb_head_tail, no_real_insns_p): Skip boundary debug insns. (queue_to_ready): Skip and discount debug insns. (choose_ready): Let debug insns through. (schedule_block): Check boundary debug insns. Discount debug insns, schedule them early. Adjust whitespace. (set_priorities): Check for boundary debug insns. (add_jump_dependencies): Use dep_list_size. (prev_non_location_insn): New. (check_cfg): Use it. * tree-ssa-loop-ivopts.c (find-interesting_users): Skip debug stmts. (remove_unused_ivs): Reset debug stmts. * modulo-sched.c (const_iteration_count): Skip debug insns. (res_MII): Discount debug insns. (loop_single_full_bb_p): Skip debug insns. (sms_schedule): Likewise. (sms_schedule_by_order): Likewise. (ps_has_conflicts): Likewise. * caller-save.c (refmarker_fn): New. (save_call_clobbered_regs): Replace regs with saved mem in debug insns. (mark_referenced_regs): Take pointer, mark and arg. Adjust. Call refmarker_fn mark for hardregnos. (mark_reg_as_referenced): New. (replace_reg_with_saved_mem): New. * ipa-pure-const.c (check_stmt): Skip debug stmts. * cse.c (cse_insn): Canonicalize debug insns. Skip them when searching back. (cse_extended_basic_block): Skip debug insns. (count_reg_usage): Likewise. (is_dead_reg): New, split out of... (set_live_p): ... here. (insn_live_p): Use it for debug insns. * tree-stdarg.c (check_all_va_list_escapes): Skip debug stmts. (execute_optimize_stdarg): Likewise. * tree-ssa-dom.c (propagate_rhs_into_lhs): Likewise. * tree-ssa-propagate.c (substitute_and_fold): Don't regard changes in debug stmts as changes. * sel-sched.c (moving_insn_creates_bookkeeping_block_p): New. (moveup_expr): Don't move across debug insns. Don't move debug insn if it would create a bookkeeping block. (moveup_expr_cached): Don't use cache for debug insns that are heads of blocks. (compute_av_set_inside_bb): Skip debug insns. (sel_rank_for_schedule): Schedule debug insns first. Remove dead code. (block_valid_for_bookkeeping_p); Support lax searches. (create_block_for_bookkeeping): Adjust block numbers when encountering debug-only blocks. (find_place_for_bookkeeping): Deal with debug-only blocks. (generate_bookkeeping_insn): Accept no place to insert. (remove_temp_moveop_nops): New argument full_tidying. (prepare_place_to_insert): Deal with debug insns. (advance_state_on_fence): Debug insns don't start cycles. (update_boundaries): Take fence as argument. Deal with debug insns. (schedule_expr_on_boundary): No full_tidying on debug insns. (fill_insns): Deal with debug insns. (track_scheduled_insns_and_blocks): Don't count debug insns. (need_nop_to_preserve_insn_bb): New, split out of... (remove_insn_from_stream): ... this. (fur_orig_expr_not_found): Skip debug insns. * rtl.def (VALUE): Move up. (DEBUG_INSN): New. * tree-ssa-sink.c (all_immediate_uses_same_place): Skip debug stmts. (nearest_common_dominator_of_uses): Take debug_stmts argument. Set it if debug stmts are found. (statement_sink_location): Skip debug stmts. Propagate moving defs into debug stmts. * ifcvt.c (first_active_insn): Skip debug insns. (last_active_insns): Likewise. (cond_exec_process_insns): Likewise. (noce_process_if_block): Likewise. (check_cond_move_block): Likewise. (cond_move_convert_if_block): Likewise. (block_jumps_and_fallthru_p): Likewise. (dead_or_predicable): Likewise. * dwarf2out.c (debug_str_hash_forced): New. (find_AT_string): Add comment. (gen_label_for_indirect_string): New. (get_debug_string_label): New. (AT_string_form): Use it. (mem_loc_descriptor): Handle non-TLS symbols. Handle MINUS , DIV, MOD, AND, IOR, XOR, NOT, ABS, NEG, and CONST_STRING. Accept but discard COMPARE, IF_THEN_ELSE, ROTATE, ROTATERT, TRUNCATE and several operations that cannot be represented with DWARF opcodes. (loc_descriptor): Ignore SIGN_EXTEND and ZERO_EXTEND. Require dwarf_version 4 for DW_OP_implicit_value and DW_OP_stack_value. (dwarf2out_var_location): Take during-call mark into account. (output_indirect_string): Update comment. Output if there are label and references. (prune_indirect_string): New. (prune_unused_types): Call it if debug_str_hash_forced. More in dwarf2out.c, from Jakub Jelinek : (dw_long_long_const): Remove. (struct dw_val_struct): Change val_long_long type to rtx. (print_die, attr_checksum, same_dw_val_p, loc_descriptor): Adjust for val_long_long change to CONST_DOUBLE rtx from a long hi/lo pair. (output_die): Likewise. Use HOST_BITS_PER_WIDE_INT size of each component instead of HOST_BITS_PER_LONG. (output_loc_operands): Likewise. For const8* assert HOST_BITS_PER_WIDE_INT rather than HOST_BITS_PER_LONG is >= 64. (output_loc_operands_raw): For const8* assert HOST_BITS_PER_WIDE_INT rather than HOST_BITS_PER_LONG is >= 64. (add_AT_long_long): Remove val_hi and val_lo arguments, add val_const_double. (size_of_die): Use HOST_BITS_PER_WIDE_INT size multiplier instead of HOST_BITS_PER_LONG for dw_val_class_long_long. (add_const_value_attribute): Adjust add_AT_long_long caller. Don't handle TLS SYMBOL_REFs. If CONST wraps a constant, tail recurse. (dwarf_stack_op_name): Handle DW_OP_implicit_value and DW_OP_stack_value. (size_of_loc_descr, output_loc_operands, output_loc_operands_raw): Handle DW_OP_implicit_value. (extract_int): Move prototype earlier. (mem_loc_descriptor): For SUBREG punt if inner mode size is wider than DWARF2_ADDR_SIZE. Handle SIGN_EXTEND and ZERO_EXTEND by DW_OP_shl and DW_OP_shr{a,}. Handle EQ, NE, GT, GE, LT, LE, GTU, GEU, LTU, LEU, SMIN, SMAX, UMIN, UMAX, SIGN_EXTRACT, ZERO_EXTRACT. (loc_descriptor): Compare mode size with DWARF2_ADDR_SIZE instead of Pmode size. (loc_descriptor): Add MODE argument. Handle CONST_INT, CONST_DOUBLE, CONST_VECTOR, CONST, LABEL_REF and SYMBOL_REF if mode != VOIDmode, attempt to handle other expressions. Don't handle TLS SYMBOL_REFs. (concat_loc_descriptor, concatn_loc_descriptor, loc_descriptor_from_tree_1): Adjust loc_descriptor callers. (add_location_or_const_value_attribute): Likewise. For single location loc_lists attempt to use add_const_value_attribute for constant decls. Add DW_AT_const_value even if NOTE_VAR_LOCATION is VAR_LOCATION with CONSTANT_P or CONST_STRING in its expression. * cfgbuild.c (inside_basic_block_p): Handle debug insns. (control_flow_insn_p): Likewise. * tree-parloops.c (eliminate_local_variables_stmt): Handle debug stmt. (separate_decls_in_region_debug_bind): New. (separate_decls_in_region): Process debug bind stmts afterwards. * recog.c (verify_changes): Handle debug insns. (extract_insn): Likewise. (peephole2_optimize): Skip debug insns. * dse.c (scan_insn): Skip debug insns. * sel-sched-ir.c (return_nop_to_pool): Take full_tidying argument. Pass it on. (setup_id_for_insn): Handle debug insns. (maybe_tidy_empty_bb): Adjust whitespace. (tidy_control_flow): Skip debug insns. (sel_remove_insn): Adjust for debug insns. (sel_estimate_number_of_insns): Skip debug insns. (create_insn_rtx_from_pattern): Handle debug insns. (create_copy_of_insn_rtx): Likewise. * sel-sched-.h (sel_bb_end): Declare. (sel_bb_empty_or_nop_p): New. (get_all_loop_exits): Use it. (_eligible_successor_edge_p): Likewise. (return_nop_to_pool): Adjust. * tree-eh.c (tre_empty_eh_handler_p): Skip debug stmts. * ira-lives.c (process_bb_node_lives): Skip debug insns. * gimple-pretty-print.c (dump_gimple_debug): New. (dump_gimple_stmt): Use it. (dump_bb_header): Skip gimple debug stmts. * regmove.c (optimize_reg_copy_1): Discount debug insns. (fixup_match_2): Likewise. (regmove_backward_pass): Likewise. Simplify combined replacement. Handle debug insns. * function.c (instantiate_virtual_regs): Handle debug insns. * function.h (struct emit_status): Add x_cur_debug_insn_uid. * print-rtl.h: Include cselib.h. (print_rtx): Print VALUEs. Split out and recurse for VAR_LOCATIONs. * df.h (df_inns_rescan_debug_internal): Declare. * gcse.c (alloc_hash_table): Estimate n_insns. (cprop_insn): Don't regard debug insns as changes. (bypass_conditional_jumps): Skip debug insns. (one_pre_gcse_pass): Adjust. (one_code_hoisting_pass): Likewise. (compute_ld_motion_mems): Skip debug insns. (one_cprop_pass): Adjust. * tree-if-conv.c (tree_if_convert_stmt): Reset debug stmts. (if_convertible_stmt_p): Handle debug stmts. * init-regs.c (initialize_uninitialized_regs): Skip debug insns. * tree-vect-loop.c (vect_is_simple_reduction): Skip debug stmts. * ira-build.c (create_bb_allocnos): Skip debug insns. * tree-flow-inline.h (has_zero_uses): Discount debug stmts. (has_single_use): Likewise. (single_imm_use): Likewise. (num_imm_uses): Likewise. * tree-ssa-phiopt.c (empty_block_p): Skip debug stmts. * tree-ssa-coalesce.c (build_ssa_conflict_graph): Skip debug stmts. (create_outofssa_var_map): Likewise. * lower-subreg.c (adjust_decomposed_uses): New. (resolve_debug): New. (decompose_multiword_subregs): Use it. * tree-dfa.c (find_referenced_vars): Skip debug stmts. * emit-rtl.c: Include params.h. (cur_debug_insn_uid): Define. (set_new_first_and_last_insn): Set cur_debug_insn_uid too. (copy_rtx_if_shared_1): Handle debug insns. (reset_used_flags): Likewise. (set_used_flags): LIkewise. (get_max_insn_count): New. (next_nondebug_insn): New. (prev_nondebug_insn): New. (make_debug_insn_raw): New. (emit_insn_before_noloc): Handle debug insns. (emit_jump_insn_before_noloc): Likewise. (emit_call_insn_before_noloc): Likewise. (emit_debug_insn_before_noloc): New. (emit_insn_after_noloc): Handle debug insns. (emit_jump_insn_after_noloc): Likewise. (emit_call_insn_after_noloc): Likewise. (emit_debug_insn_after_noloc): Likewise. (emit_insn_after): Take loc from earlier non-debug insn. (emit_jump_insn_after): Likewise. (emit_call_insn_after): Likewise. (emit_debug_insn_after_setloc): New. (emit_debug_insn_after): New. (emit_insn_before): Take loc from later non-debug insn. (emit_jump_insn_before): Likewise. (emit_call_insn_before): Likewise. (emit_debug_insn_before_setloc): New. (emit_debug_insn_before): New. (emit_insn): Handle debug insns. (emit_debug_insn): New. (emit_jump_insn): Handle debug insns. (emit_call_insn): Likewise. (emit): Likewise. (init_emit): Take min-nondebug-insn-uid into account. Initialize cur_debug_insn_uid. (emit_copy_of_insn_after): Handle debug insns. * cfgexpand.c (gimple_assign_rhs_to_tree): Do not overwrite location of single rhs in place. (maybe_dump_rtl_for_gimple_stmt): Dump lineno. (floor_sdiv_adjust): New. (cell_sdiv_adjust): New. (cell_udiv_adjust): New. (round_sdiv_adjust): New. (round_udiv_adjust): New. (wrap_constant): Moved from cselib. (unwrap_constant): New. (expand_debug_expr): New. (expand_debug_locations): New. (expand_gimple_basic_block): Drop hiding redeclaration. Expand debug bind stmts. (gimple_expand_cfg): Expand debug locations. * cselib.c: Include tree-pass.h. (struct expand_value_data): New. (cselib_record_sets_hook): New. (PRESERVED_VALUE_P, LONG_TERM_PRESERVED_VALUE_P): New. (cselib_clear_table): Move, and implemnet in terms of... (cselib_reset_table_with_next_value): ... this. (cselib_get_next_unknown_value): New. (discard_useless_locs): Don't discard preserved values. (cselib_preserve_value): New. (cselib_preserved_value_p): New. (cselib_preserve_definitely): New. (cselib_clear_preserve): New. (cselib_preserve_only_values): New. (new_cselib_val): Take rtx argument. Dump it in details. (cselib_lookup_mem): Adjust. (expand_loc): Take regs_active in struct. Adjust. Silence dumps unless details are requested. (cselib_expand_value_rtx_cb): New. (cselib_expand_value_rtx): Rename and reimplment in terms of... (cselib_expand_value_rtx_1): ... this. Adjust. Silence dumps without details. Copy more subregs. Try to resolve values using a callback. Wrap constants. (cselib_subst_to_values): Adjust. (cselib_log_lookup): New. (cselib_lookup): Call it. (cselib_invalidate_regno): Don't count preserved values as useless. (cselib_invalidate_mem): Likewise. (cselib_record_set): Likewise. (struct set): Renamed to cselib_set, moved to cselib.h. (cselib_record_sets): Adjust. Call hook. (cselib_process_insn): Reset table when it would be cleared. (dump_cselib_val): New. (dump_cselib_table): New. * tree-cfgcleanup.c (tree_forwarded_block_p): Skip debug stmts. (remove_forwarder_block): Support moving debug stmts. * cselib.h (cselib_record_sets_hook): Declare. (cselib_expand_callback): New type. (cselib_expand_value_rtx_cb): Declare. (cselib_reset_table_with_next_value): Declare. (cselib_get_next_unknown_value): Declare. (cselib_preserve_value): Declare. (cselib_preserved_value_p): Declare. (cselib_preserve_only_values): Declare. (dump_cselib_table): Declare. * cfgcleanup.c (flow_find_cross_jump): Skip debug insns. (try_crossjump_to_edge): Likewise. (delete_unreachable_blocks): Remove dominant GIMPLE blocks after dominated blocks when debug stmts are present. * simplify-rtx.c (delegitimize_mem_from_attrs): New. * tree-ssa-live.c (remove_unused_locals): Skip debug stmts. (set_var_live_on_entry): Likewise. * loop-invariant.c (find_invariants_bb): Skip debug insns. * cfglayout.c (curr_location, last_location): Make static. (set_curr_insn_source_location): Don't avoid bouncing. (get_curr_insn_source_location): New. (get_curr_insn_block): New. (duplicate_insn_chain): Handle debug insns. * tree-ssa-forwprop.c (forward_propagate_addr_expr): Propagate into debug stmts. * common.opt (fcompare-debug): Move to sort order. (fdump-unnumbered-links): Likewise. (fvar-tracking-assignments): New. (fvar-tracking-assignments-toggle): New. * tree-ssa-dce.c (mark_stmt_necessary): Don't mark blocks because of debug stmts. (mark_stmt_if_obviously_necessary): Mark debug stmts. (eliminate_unnecessary_stmts): Walk dominated blocks before dominators. * tree-ssa-ter.c (find_replaceable_in_bb): Skip debug stmts. * ira.c (memref_used_between_p): Skip debug insns. (update_equiv_regs): Likewise. * sched-deps.c (sd_lists_size): Accept empty list. (sd_init_insn): Mark debug insns. (sd_finish_insn): Unmark them. (sd_add_dep): Reject non-debug deps on debug insns. (fixup_sched_groups): Give debug insns group treatment. Skip debug insns. (sched_analyze_reg): Don't mark debug insns for sched before call. (sched_analyze_2): Handle debug insns. (sched_analyze_insn): Compute next non-debug insn. Handle debug insns. (deps_analyze_insn): Handle debug insns. (deps_start_bb): Skip debug insns. (init_deps): Initialize last_debug_insn. * tree-ssa.c (target_for_debug_bind): New. (find_released_ssa_name): New. (propagate_var_def_into_debug_stmts): New. (propagate_defs_into_debug_stmts): New. (verify_ssa): Skip debug bind stmts without values. (warn_uninialized_vars): Skip debug stmts. * target-def.h (TARGET_DELEGITIMIZE_ADDRESS): Set default. * rtl.c (rtx_equal_p_cb): Handle VALUEs. (rtx_equal_p): Likewise. * ira-costs.c (scan_one_insn): Skip debug insns. (process_bb_node_for_hard_reg_moves): Likewise. * rtl.h (DEBUG_INSN_P): New. (NONDEBUG_INSN_P): New. (MAY_HAVE_DEBUG_INSNS): New. (INSN_P): Accept debug insns. (RTX_FRAME_RELATED_P): Likewise. (INSN_DELETED_P): Likewise (PAT_VAR_LOCATION_DECL): New. (PAT_VAR_LOCATION_LOC): New. (PAT_VAR_OCATION_STATUS): New. (NOTE_VAR_LOCATION_DECL): Reimplement. (NOTE_VAR_LOCATION_LOC): Likewise. (NOTE_VAR_LOCATION_STATUS): Likewise. (INSN_VAR_LOCATION): New. (INSN_VAR_LOCATION_DECL): New. (INSN_VAR_LOCATION_LOC): New. (INSN_VAR_LOCATION_STATUS): New. (gen_rtx_UNKNOWN_VAR_LOC): New. (VAR_LOC_UNKNOWN_P): New. (NOTE_DURING_CALL_P): New. (SCHED_GROUP_P): Accept debug insns. (emit_debug_insn_before): Declare. (emit_debug_insn_before_noloc): Declare. (emit_debug_insn_beore_setloc): Declare. (emit_debug_insn_after): Declare. (emit_debug_insn_after_noloc): Declare. (emit_debug_insn_after_setloc): Declare. (emit_debug_insn): Declare. (make_debug_insn_raw): Declare. (prev_nondebug_insn): Declare. (next_nondebug_insn): Declare. (delegitimize_mem_from_attrs): Declare. (get_max_insn_count): Declare. (wrap_constant): Declare. (unwrap_constant): Declare. (get_curr_insn_source_location): Declare. (get_curr_insn_block): Declare. * tree-inline.c (insert_debug_decl_map): New. (processing_debug_stmt): New. (remap_decl): Don't create new mappings in debug stmts. (remap_gimple_op_r): Don't add references in debug stmts. (copy_tree_body_r): Likewise. (remap_gimple_stmt): Handle debug bind stmts. (copy_bb): Skip debug stmts. (copy_edges_for_bb): Likewise. (copy_debug_stmt): New. (copy_debug_stmts): New. (copy_body): Copy debug stmts at the end. (insert_init_debug_bind): New. (insert_init_stmt): Take id. Skip and emit debug stmts. (setup_one_parameter): Remap variable earlier, register debug mapping. (estimate_num_insns): Skip debug stmts. (expand_call_inline): Preserve debug_map. (optimize_inline_calls): Check for no debug_stmts left-overs. (unsave_expr_now): Preserve debug_map. (copy_gimple_seq_and_replace_locals): Likewise. (tree_function_versioning): Check for no debug_stmts left-overs. Init and destroy debug_map as needed. Split edges unconditionally. (build_duplicate_type): Init and destroy debug_map as needed. * tree-inline.h: Include gimple.h instead of pointer-set.h. (struct copy_body_data): Add debug_stmts and debug_map. * sched-int.h (struct ready_list): Add n_debug. (struct deps): Add last_debug_insn. (DEBUG_INSN_SCHED_P): New. (BOUNDARY_DEBUG_INSN_P): New. (SCHEDULE_DEBUG_INSN_P): New. (sd_iterator_cond): Accept empty list. * combine.c (create_log_links): Skip debug insns. (combine_instructions): Likewise. (cleanup_auto_inc_dec): New. From Jakub Jelinek: Make sure the return value is always unshared. (struct rtx_subst_pair): New. (auto_adjust_pair): New. (propagate_for_debug_subst): New. (propagate_for_debug): New. (try_combine): Skip debug insns. Propagate removed defs into debug insns. (next_nonnote_nondebug_insn): New. (distribute_notes): Use it. Skip debug insns. (distribute_links): Skip debug insns. * tree-outof-ssa.c (set_location_for_edge): Likewise. * resource.c (mark_target_live_regs): Likewise. * var-tracking.c: Include cselib.h and target.h. (enum micro_operation_type): Add MO_VAL_USE, MO_VAL_LOC, and MO_VAL_SET. (micro_operation_type_name): New. (enum emit_note_where): Add EMIT_NOTE_AFTER_CALL_INSN. (struct micro_operation_def): Update comments. (decl_or_value): New type. Use instead of decls. (struct emit_note_data_def): Add vars. (struct attrs_def): Use decl_or_value. (struct variable_tracking_info_def): Add permp, flooded. (struct location_chain_def): Update comment. (struct variable_part_def): Use decl_or_value. (struct variable_def): Make var_part a variable length array. (valvar_pool): New. (scratch_regs): New. (cselib_hook_called): New. (dv_is_decl_p): New. (dv_is_value_p): New. (dv_as_decl): New. (dv_as_value): New. (dv_as_opaque): New. (dv_onepart_p): New. (dv_pool): New. (IS_DECL_CODE): New. (check_value_is_not_decl): New. (dv_from_decl): New. (dv_from_value): New. (dv_htab_hash): New. (variable_htab_hash): Use it. (variable_htab_eq): Support values. (variable_htab_free): Free from the right pool. (attrs_list_member, attrs_list_insert): Use decl_or_value. (attrs_list_union): Adjust. (attrs_list_mpdv_union): New. (tie_break_pointers): New. (canon_value_cmp): New. (unshare_variable): Return possibly-modified slot. (vars_copy_1): Adjust. (var_reg_decl_set): Adjust. Split out of... (var_reg_set): ... this. (get_init_value): Adjust. (var_reg_delete_and_set): Adjust. (var_reg_delete): Adjust. (var_regno_delete): Adjust. (var_mem_decl_set): Split out of... (var_mem_set): ... this. (var_mem_delete_and_set): Adjust. (var_mem_delete): Adjust. (val_store): New. (val_reset): New. (val_resolve): New. (variable_union): Adjust. Speed up merge of 1-part vars. (variable_canonicalize): Use unshared slot. (VALUED_RECURSED_INTO): New. (find_loc_in_1pdv): New. (struct dfset_merge): New. (insert_into_intersection): New. (intersect_loc_chains): New. (loc_cmp): New. (canonicalize_loc_order_check): New. (canonicalize_values_mark): New. (canonicalize_values_star): New. (variable_merge_over_cur): New. (variable_merge_over_src): New. (dataflow_set_merge): New. (dataflow_set_equiv_regs): New. (remove_duplicate_values): New. (struct dfset_post_merge): New. (variable_post_merge_new_vals): New. (variable_post_merge_perm_vals): New. (dataflow_post_merge_adjust): New. (find_mem_expr_in_1pdv): New. (dataflow_set_preserve_mem_locs): New. (dataflow_set_remove_mem_locs): New. (dataflow_set_clear_at_call): New. (onepart_variable_different_p): New. (variable_different_p): Use it. (dataflow_set_different_1): Adjust. Make detailed dump more verbose. (track_expr_p): Add need_rtl parameter. Don't generate rtl if not needed. (track_loc_p): Pass it true. (struct count_use_info): New. (find_use_val): New. (replace_expr_with_values): New. (log_op_type): New. (use_type): New, partially split out of... (count_uses): ... this. Count new micro-ops. (count_uses_1): Adjust. (count_stores): Adjust. (count_with_sets): New. (VAL_NEEDS_RESOLUTION): New. (VAL_HOLDS_TRACK_EXPR): New. (VAL_EXPR_IS_COPIED): New. (VAL_EXPR_IS_CLOBBERED): New. (add_uses): Adjust. Generate new micro-ops. (add_uses_1): Adjust. (add_stores): Generate new micro-ops. (add_with_sets): New. (find_src_status): Adjust. (find_src_set_src): Adjust. (compute_bb_dataflow): Use dataflow_set_clear_at_call. Handle new micro-ops. Canonicalize value equivalances. (vt_find_locations): Compute total size of hash tables for dumping. Perform merge for var-tracking-assignments. Don't disregard single-block loops. (dump_attrs_list): Handle decl_or_value. (dump_variable): Take variable. Deal with decl_or_value. (dump_variable_slot): New. (dump_vars): Use it. (dump_dataflow_sets): Adjust. (set_slot_part): New, extended to support one-part variables after splitting out of... (set_variable_part): ... this. (clobber_slot_part): New, split out of... (clobber_variable_part): ... this. (delete_slot_part): New, split out of... (delete_variable_part): .... this. (check_wrap_constant): New. (vt_expand_loc_callback): New. (vt_expand_loc): New. (emit_note_insn_var_location): Adjust. Handle values. Handle EMIT_NOTE_AFTER_CALL_INSN. (emit_notes_for_differences_1): Adjust. Handle values. (emit_notes_for_differences_2): Likewise. (emit_notes_for_differences): Adjust. (emit_notes_in_bb): Take pointer to set. Emit AFTER_CALL_INSN notes. Adjust. Handle new micro-ops. (vt_add_function_parameters): Adjust. Create and bind values. (vt_initialize): Adjust. Initialize scratch_regs and valvar_pool, flooded and perm.. Initialize and use cselib. Log operations. Move some code to count_with_sets and add_with_sets. (delete_debug_insns): New. (vt_debug_insns_local): New. (vt_finalize): Release permp, valvar_pool, scratch_regs. Finish cselib. (var_tracking_main): If var-tracking-assignments is enabled but var-tracking isn't, delete debug insns and leave. Likewise if we exceed limits or fail the stack adjustments tests, and after all var-tracking processing. More in var-tracking, from Jakub Jelinek : (dataflow_set): Add traversed_vars. (value_chain, const_value_chain): New typedefs. (value_chain_pool, value_chains): New variables. (value_chain_htab_hash, value_chain_htab_eq, add_value_chain, add_value_chains, add_cselib_value_chains, remove_value_chain, remove_value_chains, remove_cselib_value_chains): New functions. (shared_hash_find_slot_unshare_1, shared_hash_find_slot_1, shared_hash_find_slot_noinsert_1, shared_hash_find_1): New static inlines. (shared_hash_find_slot_unshare, shared_hash_find_slot, shared_hash_find_slot_noinsert, shared_hash_find): Update. (dst_can_be_shared): New variable. (unshare_variable): Unshare set->vars if shared, use shared_hash_*. Clear dst_can_be_shared. If set->traversed_vars is non-NULL and different from set->vars, look up slot again instead of using the passed in slot. (dataflow_set_init): Initialize traversed_vars. (variable_union): Use shared_hash_*. Use initially NO_INSERT lookup if set->vars is shared. Don't keep slot cleared before calling unshare_variable. Unshare set->vars if needed. Adjust unshare_variable callers. Clear dst_can_be_shared if needed. Even ->refcount == 1 vars must be unshared if set->vars is shared and var needs to be modified. (dataflow_set_union): Set traversed_vars during canonicalization. (VALUE_CHANGED, DECL_CHANGED): Define. (set_dv_changed, dv_changed_p): New static inlines. (track_expr_p): Clear DECL_CHANGED. (dump_dataflow_sets): Set it. (variable_was_changed): Call set_dv_changed. (emit_note_insn_var_location): Likewise. (changed_variables_stack): New variable. (check_changed_vars_1, check_changed_vars_2): New functions. (emit_notes_for_changes): Do nothing if changed_variables is empty. Traverse changed_variables with check_changed_vars_1, call check_changed_vars_2 on each changed_variables_stack entry. (emit_notes_in_bb): Add SET argument. Just clear it at the beginning, use it instead of local &set, don't destroy it at the end. (vt_emit_notes): Call dataflow_set_clear early on all VTI(bb)->out sets, never use them, instead use emit_notes_in_bb computed set, dataflow_set_clear also VTI(bb)->in when we are done with the basic block. Initialize changed_variables_stack, free it afterwards. If ENABLE_CHECKING verify that after noting differences to an empty set value_chains hash table is empty. (vt_initialize): Initialize value_chains and value_chain_pool. (vt_finalize): Delete value_chains htab, free value_chain_pool. (variable_tracking_main): Call dump_dataflow_sets before calling vt_emit_notes, not after it. * tree-flow.h (propagate_defs_into_debug_stmts): Declare. (propagate_var_def_into_debug_stmts): Declare. * df-problems.c (df_lr_bb_local_compute): Skip debug insns. (df_set_note): Reject debug insns. (df_whole_mw_reg_dead_p): Take added_notes_p argument. Don't add notes to debug insns. (df_note_bb_compute): Adjust. Likewise. (df_simulate_uses): Skip debug insns. (df_simulate_initialize_backwards): Likewise. * reg-stack.c (subst_stack_regs_in_debug_insn): New. (subst_stack_regs_pat): Reject debug insns. (convert_regs_1): Handle debug insns. * Makefile.in (TREE_INLINE_H): Take pointer-set.h from GIMPLE_H. (print-rtl.o): Depend on cselib.h. (cselib.o): Depend on TREE_PASS_H. (var-tracking.o): Depend on cselib.h and TARGET_H. * sched-rgn.c (rgn_estimate_number_of_insns): Discount debug insns. (init_ready_list): Skip boundary debug insns. (add_branch_dependences): Skip debug insns. (free_block_dependencies): Check for blocks with only debug insns. (compute_priorities): Likewise. * gimple.c (gss_for_code): Handle GIMPLE_DEBUG. (gimple_build_with_ops_stat): Take subcode as unsigned. Adjust all callers. (gimple_build_debug_bind_stat): New. (empty_body_p): Skip debug stmts. (gimple_has_side_effects): Likewise. (gimple_rhs_has_side_effects): Likewise. * gimple.h (enum gimple_debug_subcode, GIMPLE_DEBUG_BIND): New. (gimple_build_debug_bind_stat): Declare. (gimple_build_debug_bind): Define. (is_gimple_debug): New. (gimple_debug_bind_p): New. (gimple_debug_bind_get_var): New. (gimple_debug_bind_get_value): New. (gimple_debug_bind_get_value_ptr): New. (gimple_debug_bind_set_var): New. (gimple_debug_bind_set_value): New. (GIMPLE_DEBUG_BIND_NOVALUE): New internal temporary macro. (gimple_debug_bind_reset_value): New. (gimple_debug_bind_has_value_p): New. (gsi_next_nondebug): New. (gsi_prev_nondebug): New. (gsi_start_nondebug_bb): New. (gsi_last_nondebug_bb): New. * sched-vis.c (print_pattern): Handle VAR_LOCATION. (print_insn): Handle DEBUG_INSN. * tree-cfg.c (remove_bb): Walk stmts backwards. Let loc of first insn prevail. (first_stmt): Skip debug stmts. (first_non_label_stmt): Likewise. (last_stmt): Likewise. (has_zero_uses_1): New. (single_imm_use_1): New. (verify_gimple_debug): New. (verify_types_in_gimple_stmt): Handle debug stmts. (verify_stmt): Likewise. (debug_loop_num): Skip debug stmts. (remove_edge_and_dominated_blocks): Remove dominators last. * tree-ssa-reasssoc.c (rewrite_expr_tree): Propagate into debug stmts. (linearize_expr): Likewise. * config/i386/i386.c (ix86_delegitimize_address): Call default implementation. * config/ia64/ia64.c (ia64_safe_itanium_class): Handle debug insns. (group_barrier_needed): Skip debug insns. (emit_insn_group_barriers): Likewise. (emit_all_insn_group_barriers): Likewise. (ia64_variable_issue): Handle debug insns. (ia64_dfa_new_cycle): Likewise. (final_emit_insn_group_barriers): Skip debug insns. (ia64_dwarf2out_def_steady_cfa): Take frame argument. Don't def cfa without frame. (process_set): Likewise. (process_for_unwind_directive): Pass frame on. * config/rs6000/rs6000.c (TARGET_DELEGITIMIZE_ADDRESS): Define. (rs6000_delegitimize_address): New. (rs6000_debug_adjust_cost): Handle debug insns. (is_microcoded_insn): Likewise. (is_cracked_insn): Likewise. (is_nonpipeline_insn): Likewise. (insn_must_be_first_in_group): Likewise. (insn_must_be_last_in_group): Likewise. (force_new_group): Likewise. * cfgrtl.c (rtl_split_block): Emit INSN_DELETED note if block contains only debug insns. (rtl_merge_blocks): Skip debug insns. (purge_dead_edges): Likewise. (rtl_block_ends_with_call_p): Skip debug insns. * dce.c (deletable_insn_p): Handle VAR_LOCATION. (mark_reg_dependencies): Skip debug insns. * params.def (PARAM_MIN_NONDEBUG_INSN_UID): New. * tree-ssanames.c (release_ssa_name): Propagate def into debug stmts. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts): Skip debug stmts. * regcprop.c (replace_oldest_value_addr): Skip debug insns. (replace_oldest_value_mem): Use ALL_REGS for debug insns. (copyprop_hardreg_forward_1): Handle debug insns. * reload1.c (reload): Skip debug insns. Replace unassigned pseudos in debug insns with their equivalences. (eliminate_regs_in_insn): Skip debug insns. (emit_input_reload_insns): Skip debug insns at first, adjust them later. * tree-ssa-operands.c (add_virtual_operand): Reject debug stmts. (get_indirect_ref_operands): Pass opf_no_vops on. (get_expr_operands): Likewise. Skip debug stmts. (parse_ssa_operands): Scan debug insns with opf_no_vops. gcc/testsuite/ChangeLog: * gcc.dg/guality/guality.c: New. * gcc.dg/guality/guality.h: New. * gcc.dg/guality/guality.exp: New. * gcc.dg/guality/example.c: New. * lib/gcc-dg.exp (cleanup-dump): Remove .gk files. (cleanup-saved-temps): Likewise, .gkd files too. gcc/cp/ChangeLog: * cp-tree.h (TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS): New. * cp-lang.c (cxx_dwarf_name): Pass it. * error.c (count_non_default_template_args): Take flags as argument. Adjust all callers. Skip counting of default arguments if the new flag is given. ChangeLog: * Makefile.tpl (BUILD_CONFIG): Default to bootstrap-debug. * Makefile.in: Rebuilt. contrib/ChangeLog: * compare-debug: Look for .gkd files and compare them. config/ChangeLog: * bootstrap-debug.mk: Add comments. * bootstrap-debug-big.mk: New. * bootstrap-debug-lean.mk: New. * bootstrap-debug-ckovw.mk: Add comments. * bootstrap-debug-lib.mk: Drop CFLAGS for stages. Use -g0 for TFLAGS in stage1. Drop -fvar-tracking-assignments-toggle. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151312 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 314 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 261 insertions(+), 53 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 97c9261b469..fbd973b4281 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -147,6 +147,30 @@ insert_decl_map (copy_body_data *id, tree key, tree value) *pointer_map_insert (id->decl_map, value) = value; } +/* Insert a tree->tree mapping for ID. This is only used for + variables. */ + +static void +insert_debug_decl_map (copy_body_data *id, tree key, tree value) +{ + if (!gimple_in_ssa_p (id->src_cfun)) + return; + + if (!MAY_HAVE_DEBUG_STMTS) + return; + + if (!target_for_debug_bind (key)) + return; + + gcc_assert (TREE_CODE (key) == PARM_DECL); + gcc_assert (TREE_CODE (value) == VAR_DECL); + + if (!id->debug_map) + id->debug_map = pointer_map_create (); + + *pointer_map_insert (id->debug_map, key) = value; +} + /* Construct new SSA name for old NAME. ID is the inline context. */ static tree @@ -220,6 +244,12 @@ remap_ssa_name (tree name, copy_body_data *id) return new_tree; } +/* If nonzero, we're remapping the contents of inlined debug + statements. If negative, an error has occurred, such as a + reference to a variable that isn't available in the inlined + context. */ +int processing_debug_stmt = 0; + /* Remap DECL during the copying of the BLOCK tree for the function. */ tree @@ -235,6 +265,12 @@ remap_decl (tree decl, copy_body_data *id) n = (tree *) pointer_map_contains (id->decl_map, decl); + if (!n && processing_debug_stmt) + { + processing_debug_stmt = -1; + return decl; + } + /* If we didn't already have an equivalent for this declaration, create one now. */ if (!n) @@ -812,7 +848,8 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) vars. If not referenced from types only. */ if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL - && id->remapping_type_depth == 0) + && id->remapping_type_depth == 0 + && !processing_debug_stmt) add_referenced_var (*tp); /* We should never have TREE_BLOCK set on non-statements. */ @@ -1043,10 +1080,11 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) copy_tree_r (tp, walk_subtrees, NULL); /* Global variables we haven't seen yet needs to go into referenced - vars. If not referenced from types only. */ + vars. If not referenced from types or debug stmts only. */ if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL - && id->remapping_type_depth == 0) + && id->remapping_type_depth == 0 + && !processing_debug_stmt) add_referenced_var (*tp); /* If EXPR has block defined, map it to newly constructed block. @@ -1292,8 +1330,17 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) } } - /* Create a new deep copy of the statement. */ - copy = gimple_copy (stmt); + if (gimple_debug_bind_p (stmt)) + { + copy = gimple_build_debug_bind (gimple_debug_bind_get_var (stmt), + gimple_debug_bind_get_value (stmt), + stmt); + VEC_safe_push (gimple, heap, id->debug_stmts, copy); + return copy; + } + else + /* Create a new deep copy of the statement. */ + copy = gimple_copy (stmt); } /* If STMT has a block defined, map it to the newly constructed @@ -1310,6 +1357,9 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) gimple_set_block (copy, new_block); + if (gimple_debug_bind_p (copy)) + return copy; + /* Remap all the operands in COPY. */ memset (&wi, 0, sizeof (wi)); wi.info = id; @@ -1604,7 +1654,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, add_stmt_to_eh_region (stmt, id->eh_region); } - if (gimple_in_ssa_p (cfun)) + if (gimple_in_ssa_p (cfun) && !is_gimple_debug (stmt)) { ssa_op_iter i; tree def; @@ -1733,9 +1783,12 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) bool can_throw, nonlocal_goto; copy_stmt = gsi_stmt (si); - update_stmt (copy_stmt); - if (gimple_in_ssa_p (cfun)) - mark_symbols_for_renaming (copy_stmt); + if (!is_gimple_debug (copy_stmt)) + { + update_stmt (copy_stmt); + if (gimple_in_ssa_p (cfun)) + mark_symbols_for_renaming (copy_stmt); + } /* Do this before the possible split_block. */ gsi_next (&si); @@ -2011,6 +2064,82 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, return new_fndecl; } +/* Copy the debug STMT using ID. We deal with these statements in a + special way: if any variable in their VALUE expression wasn't + remapped yet, we won't remap it, because that would get decl uids + out of sync, causing codegen differences between -g and -g0. If + this arises, we drop the VALUE expression altogether. */ + +static void +copy_debug_stmt (gimple stmt, copy_body_data *id) +{ + tree t, *n; + struct walk_stmt_info wi; + + t = id->block; + if (gimple_block (stmt)) + { + tree *n; + n = (tree *) pointer_map_contains (id->decl_map, gimple_block (stmt)); + if (n) + t = *n; + } + gimple_set_block (stmt, t); + + /* Remap all the operands in COPY. */ + memset (&wi, 0, sizeof (wi)); + wi.info = id; + + processing_debug_stmt = 1; + + t = gimple_debug_bind_get_var (stmt); + + if (TREE_CODE (t) == PARM_DECL && id->debug_map + && (n = (tree *) pointer_map_contains (id->debug_map, t))) + { + gcc_assert (TREE_CODE (*n) == VAR_DECL); + t = *n; + } + else + walk_tree (&t, remap_gimple_op_r, &wi, NULL); + + gimple_debug_bind_set_var (stmt, t); + + if (gimple_debug_bind_has_value_p (stmt)) + walk_tree (gimple_debug_bind_get_value_ptr (stmt), + remap_gimple_op_r, &wi, NULL); + + /* Punt if any decl couldn't be remapped. */ + if (processing_debug_stmt < 0) + gimple_debug_bind_reset_value (stmt); + + processing_debug_stmt = 0; + + update_stmt (stmt); + if (gimple_in_ssa_p (cfun)) + mark_symbols_for_renaming (stmt); +} + +/* Process deferred debug stmts. In order to give values better odds + of being successfully remapped, we delay the processing of debug + stmts until all other stmts that might require remapping are + processed. */ + +static void +copy_debug_stmts (copy_body_data *id) +{ + size_t i; + gimple stmt; + + if (!id->debug_stmts) + return; + + for (i = 0; VEC_iterate (gimple, id->debug_stmts, i, stmt); i++) + copy_debug_stmt (stmt, id); + + VEC_free (gimple, heap, id->debug_stmts); +} + /* Make a copy of the body of SRC_FN so that it can be inserted inline in another function. */ @@ -2025,6 +2154,9 @@ copy_tree_body (copy_body_data *id) return body; } +/* Make a copy of the body of FN so that it can be inserted inline in + another function. */ + static tree copy_body (copy_body_data *id, gcov_type count, int frequency, basic_block entry_block_map, basic_block exit_block_map) @@ -2035,6 +2167,7 @@ copy_body (copy_body_data *id, gcov_type count, int frequency, /* If this body has a CFG, walk CFG and copy. */ gcc_assert (ENTRY_BLOCK_PTR_FOR_FUNCTION (DECL_STRUCT_FUNCTION (fndecl))); body = copy_cfg_body (id, count, frequency, entry_block_map, exit_block_map); + copy_debug_stmts (id); return body; } @@ -2055,8 +2188,51 @@ self_inlining_addr_expr (tree value, tree fn) return var && auto_var_in_fn_p (var, fn); } +/* Append to BB a debug annotation that binds VAR to VALUE, inheriting + lexical block and line number information from base_stmt, if given, + or from the last stmt of the block otherwise. */ + +static gimple +insert_init_debug_bind (copy_body_data *id, + basic_block bb, tree var, tree value, + gimple base_stmt) +{ + gimple note; + gimple_stmt_iterator gsi; + tree tracked_var; + + if (!gimple_in_ssa_p (id->src_cfun)) + return NULL; + + if (!MAY_HAVE_DEBUG_STMTS) + return NULL; + + tracked_var = target_for_debug_bind (var); + if (!tracked_var) + return NULL; + + if (bb) + { + gsi = gsi_last_bb (bb); + if (!base_stmt && !gsi_end_p (gsi)) + base_stmt = gsi_stmt (gsi); + } + + note = gimple_build_debug_bind (tracked_var, value, base_stmt); + + if (bb) + { + if (!gsi_end_p (gsi)) + gsi_insert_after (&gsi, note, GSI_SAME_STMT); + else + gsi_insert_before (&gsi, note, GSI_SAME_STMT); + } + + return note; +} + static void -insert_init_stmt (basic_block bb, gimple init_stmt) +insert_init_stmt (copy_body_data *id, basic_block bb, gimple init_stmt) { /* If VAR represents a zero-sized variable, it's possible that the assignment statement may result in no gimple statements. */ @@ -2068,7 +2244,8 @@ insert_init_stmt (basic_block bb, gimple init_stmt) from a rhs with a conversion. Handle that here by forcing the rhs into a temporary. gimple_regimplify_operands is not prepared to do this for us. */ - if (!is_gimple_reg (gimple_assign_lhs (init_stmt)) + if (!is_gimple_debug (init_stmt) + && !is_gimple_reg (gimple_assign_lhs (init_stmt)) && is_gimple_reg_type (TREE_TYPE (gimple_assign_lhs (init_stmt))) && gimple_assign_rhs_class (init_stmt) == GIMPLE_UNARY_RHS) { @@ -2083,6 +2260,18 @@ insert_init_stmt (basic_block bb, gimple init_stmt) gsi_insert_after (&si, init_stmt, GSI_NEW_STMT); gimple_regimplify_operands (init_stmt, &si); mark_symbols_for_renaming (init_stmt); + + if (!is_gimple_debug (init_stmt) && MAY_HAVE_DEBUG_STMTS) + { + tree var, def = gimple_assign_lhs (init_stmt); + + if (TREE_CODE (def) == SSA_NAME) + var = SSA_NAME_VAR (def); + else + var = def; + + insert_init_debug_bind (id, bb, var, def, init_stmt); + } } } @@ -2113,9 +2302,29 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (p), value); } + /* Make an equivalent VAR_DECL. Note that we must NOT remap the type + here since the type of this decl must be visible to the calling + function. */ + var = copy_decl_to_var (p, id); + + /* We're actually using the newly-created var. */ + if (gimple_in_ssa_p (cfun) && TREE_CODE (var) == VAR_DECL) + { + get_var_ann (var); + add_referenced_var (var); + } + + /* Declare this new variable. */ + TREE_CHAIN (var) = *vars; + *vars = var; + + /* Make gimplifier happy about this variable. */ + DECL_SEEN_IN_BIND_EXPR_P (var) = 1; + /* If the parameter is never assigned to, has no SSA_NAMEs created, - we may not need to create a new variable here at all. Instead, we may - be able to just use the argument value. */ + we would not need to create a new variable here at all, if it + weren't for debug info. Still, we can just use the argument + value. */ if (TREE_READONLY (p) && !TREE_ADDRESSABLE (p) && value && !TREE_SIDE_EFFECTS (value) @@ -2136,32 +2345,16 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, && ! self_inlining_addr_expr (value, fn)) { insert_decl_map (id, p, value); - return NULL; + insert_debug_decl_map (id, p, var); + return insert_init_debug_bind (id, bb, var, value, NULL); } } - /* Make an equivalent VAR_DECL. Note that we must NOT remap the type - here since the type of this decl must be visible to the calling - function. */ - var = copy_decl_to_var (p, id); - if (gimple_in_ssa_p (cfun) && TREE_CODE (var) == VAR_DECL) - { - get_var_ann (var); - add_referenced_var (var); - } - /* Register the VAR_DECL as the equivalent for the PARM_DECL; that way, when the PARM_DECL is encountered, it will be automatically replaced by the VAR_DECL. */ insert_decl_map (id, p, var); - /* Declare this new variable. */ - TREE_CHAIN (var) = *vars; - *vars = var; - - /* Make gimplifier happy about this variable. */ - DECL_SEEN_IN_BIND_EXPR_P (var) = 1; - /* Even if P was TREE_READONLY, the new VAR should not be. In the original code, we would have constructed a temporary, and then the function body would have never @@ -2183,15 +2376,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, Do replacement at -O0 for const arguments replaced by constant. This is important for builtin_constant_p and other construct requiring - constant argument to be visible in inlined function body. - - FIXME: This usually kills the last connection in between inlined - function parameter and the actual value in debug info. Can we do - better here? If we just inserted the statement, copy propagation - would kill it anyway as it always did in older versions of GCC. - - We might want to introduce a notion that single SSA_NAME might - represent multiple variables for purposes of debugging. */ + constant argument to be visible in inlined function body. */ if (gimple_in_ssa_p (cfun) && rhs && def && is_gimple_reg (p) && (optimize || (TREE_READONLY (p) @@ -2201,7 +2386,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (def)) { insert_decl_map (id, def, rhs); - return NULL; + return insert_init_debug_bind (id, bb, var, rhs, NULL); } /* If the value of argument is never used, don't care about initializing @@ -2209,7 +2394,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, if (optimize && gimple_in_ssa_p (cfun) && !def && is_gimple_reg (p)) { gcc_assert (!value || !TREE_SIDE_EFFECTS (value)); - return NULL; + return insert_init_debug_bind (id, bb, var, rhs, NULL); } /* Initialize this VAR_DECL from the equivalent argument. Convert @@ -2219,7 +2404,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, if (rhs == error_mark_node) { insert_decl_map (id, p, var); - return NULL; + return insert_init_debug_bind (id, bb, var, rhs, NULL); } STRIP_USELESS_TYPE_CONVERSION (rhs); @@ -2237,7 +2422,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, init_stmt = gimple_build_assign (var, rhs); if (bb && init_stmt) - insert_init_stmt (bb, init_stmt); + insert_init_stmt (id, bb, init_stmt); } return init_stmt; } @@ -3118,6 +3303,7 @@ estimate_num_insns (gimple stmt, eni_weights *weights) case GIMPLE_PHI: case GIMPLE_RETURN: case GIMPLE_PREDICT: + case GIMPLE_DEBUG: return 0; case GIMPLE_ASM: @@ -3262,7 +3448,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) { tree retvar, use_retvar; tree fn; - struct pointer_map_t *st; + struct pointer_map_t *st, *dst; tree return_slot; tree modify_dest; location_t saved_location; @@ -3402,6 +3588,8 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) map. */ st = id->decl_map; id->decl_map = pointer_map_create (); + dst = id->debug_map; + id->debug_map = NULL; /* Record the function we are about to inline. */ id->src_fn = fn; @@ -3498,6 +3686,11 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) } /* Clean up. */ + if (id->debug_map) + { + pointer_map_destroy (id->debug_map); + id->debug_map = dst; + } pointer_map_destroy (id->decl_map); id->decl_map = st; @@ -3726,6 +3919,8 @@ optimize_inline_calls (tree fn) fold_marked_statements (last, id.statements_to_fold); pointer_set_destroy (id.statements_to_fold); + gcc_assert (!id.debug_stmts); + /* Renumber the (code) basic_blocks consecutively. */ compact_blocks (); /* Renumber the lexical scoping (non-code) blocks consecutively. */ @@ -3961,6 +4156,7 @@ unsave_expr_now (tree expr) id.src_fn = current_function_decl; id.dst_fn = current_function_decl; id.decl_map = pointer_map_create (); + id.debug_map = NULL; id.copy_decl = copy_decl_no_change; id.transform_call_graph_edges = CB_CGE_DUPLICATE; @@ -3976,6 +4172,8 @@ unsave_expr_now (tree expr) /* Clean up. */ pointer_map_destroy (id.decl_map); + if (id.debug_map) + pointer_map_destroy (id.debug_map); return expr; } @@ -4107,6 +4305,7 @@ copy_gimple_seq_and_replace_locals (gimple_seq seq) id.src_fn = current_function_decl; id.dst_fn = current_function_decl; id.decl_map = pointer_map_create (); + id.debug_map = NULL; id.copy_decl = copy_decl_no_change; id.transform_call_graph_edges = CB_CGE_DUPLICATE; @@ -4131,6 +4330,8 @@ copy_gimple_seq_and_replace_locals (gimple_seq seq) /* Clean up. */ pointer_map_destroy (id.decl_map); + if (id.debug_map) + pointer_map_destroy (id.debug_map); return copy; } @@ -4506,7 +4707,7 @@ tree_function_versioning (tree old_decl, tree new_decl, tree p; unsigned i; struct ipa_replace_map *replace_info; - basic_block old_entry_block; + basic_block old_entry_block, bb; VEC (gimple, heap) *init_stmts = VEC_alloc (gimple, heap, 10); tree t_step; @@ -4534,8 +4735,9 @@ tree_function_versioning (tree old_decl, tree new_decl, /* Generate a new name for the new version. */ id.statements_to_fold = pointer_set_create (); - + id.decl_map = pointer_map_create (); + id.debug_map = NULL; id.src_fn = old_decl; id.dst_fn = new_decl; id.src_node = old_version_node; @@ -4637,12 +4839,12 @@ tree_function_versioning (tree old_decl, tree new_decl, /* Renumber the lexical scoping (non-code) blocks consecutively. */ number_blocks (new_decl); - if (VEC_length (gimple, init_stmts)) - { - basic_block bb = split_edge (single_succ_edge (ENTRY_BLOCK_PTR)); - while (VEC_length (gimple, init_stmts)) - insert_init_stmt (bb, VEC_pop (gimple, init_stmts)); - } + /* We want to create the BB unconditionally, so that the addition of + debug stmts doesn't affect BB count, which may in the end cause + codegen differences. */ + bb = split_edge (single_succ_edge (ENTRY_BLOCK_PTR)); + while (VEC_length (gimple, init_stmts)) + insert_init_stmt (&id, bb, VEC_pop (gimple, init_stmts)); update_clone_info (&id); /* Remap the nonlocal_goto_save_area, if any. */ @@ -4657,6 +4859,8 @@ tree_function_versioning (tree old_decl, tree new_decl, /* Clean up. */ pointer_map_destroy (id.decl_map); + if (id.debug_map) + pointer_map_destroy (id.debug_map); free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); @@ -4668,6 +4872,7 @@ tree_function_versioning (tree old_decl, tree new_decl, free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); + gcc_assert (!id.debug_stmts); VEC_free (gimple, heap, init_stmts); pop_cfun (); current_function_decl = old_current_function_decl; @@ -4742,11 +4947,14 @@ build_duplicate_type (tree type) id.dst_fn = current_function_decl; id.src_cfun = cfun; id.decl_map = pointer_map_create (); + id.debug_map = NULL; id.copy_decl = copy_decl_no_change; type = remap_type_1 (type, &id); pointer_map_destroy (id.decl_map); + if (id.debug_map) + pointer_map_destroy (id.debug_map); TYPE_CANONICAL (type) = type; -- cgit v1.2.1 From 800b8c3970d54a4aac39b351812eaf460d0e6e2f Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 11 Sep 2009 11:08:38 +0000 Subject: PR middle-end/41275 * tree-inline.c (remap_decls): Don't put DECL_EXTERNAL decls on the local_decls list. testsuite/ * g++.dg/tree-ssa/pr41275.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151631 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index fbd973b4281..b5e73467127 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -536,6 +536,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) if (can_be_nonlocal (old_var, id)) { if (TREE_CODE (old_var) == VAR_DECL + && ! DECL_EXTERNAL (old_var) && (var_ann (old_var) || !gimple_in_ssa_p (cfun))) cfun->local_decls = tree_cons (NULL_TREE, old_var, cfun->local_decls); -- cgit v1.2.1 From 58d82cd04d30e16e38e5fcac6d2d120fa55d64ed Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 13 Sep 2009 19:40:33 +0000 Subject: 2009-09-13 Richard Guenther Rafael Avila de Espindola * langhooks-def.h (LANG_HOOKS_EH_RUNTIME_TYPE): Define. (LANG_HOOKS_EH_PERSONALITY): Likewise. (LANG_HOOKS_INITIALIZER): Adjust. (lhd_pass_through_t): Declare. * langhooks.h (struct lang_hooks): Add eh_runtime_type and eh_personality. * langhooks.c (lhd_pass_through_t): New function. * dwarf2out.c (output_call_frame_info, dwarf2out_do_cfi_startproc, dwarf2out_begin_prologue): Use personality from current_function_decl. * expr.h (get_personality_function): Declare. * expr.c (get_personality_function): New function. (build_personality_function): Likewise. * libfuncs.h (libfunc_index): Remove LTI_eh_personality. (eh_personality_libfunc): Remove. * optabs.c (build_libfunc_function): New function split out from ... (init_one_libfunc): ... here. * tree.h (DECL_FUNCTION_PERSONALITY): New. (tree_function_decl): Add personality. (lhd_gcc_personality): Declare. (build_personality_function): Likewise. * tree.c (gcc_eh_personality_decl): New. (lhd_gcc_personality): New function. * except.h (lang_eh_runtime_type): Remove. (enum eh_personality_kind): New. (build_personality_function): Declare. (function_needs_eh_personality): Declare. * except.c (lang_eh_runtime_type): Remove. (function_needs_eh_personality): New function. (add_type_for_runtime): Call lang_hooks.type_for_runtime instead. (sjlj_emit_function_enter, output_function_exception_table): Use personality from current_function_decl. * tree-eh.c (lower_eh_constructs): Set DECL_FUNCTION_PERSONALITY. * tree-inline.c (tree_can_inline_p): Do not inline across different EH personalities. (expand_call_inline): Likewise. Adjust the callers EH personality. (tree_function_versioning): Copy DECL_FUNCTION_PERSONALITY. * cgraph.c (cgraph_add_new_function): Set DECL_FUNCTION_PERSONALITY. * Makefile.in (cgraph.o): Add $(EXCEPT_H) dependency. (c-parser.o): Likewise * c-tree.h (c_eh_initialized_p): Remove. (c_maybe_initialize_eh): Likewise. * c-decl.c (finish_decl): Don't call c_maybe_initialize_eh. (finish_decl): Don't call c_maybe_initialize_eh. (c_eh_initialized_p): Remove. (c_maybe_initialize_eh): Likewise. * c-parser.c (c_parser_omp_construct): Likewise. (c_parse_file): Initialize exception handling. objc/ * objc-act.c (objc_eh_runtime_type): Export. (objc_init_exceptions): Remove. Move warning code ... (objc_begin_try_stmt): ... here (objc_build_throw_stmt): ... and here. (objc_eh_personality_decl): New. (objc_eh_personality): New function. * objc-act.h (objc_eh_runtime_type): Declare. (objc_eh_personality): Likewise. * objc-lang.c (LANG_HOOKS_EH_RUNTIME_TYPE): Define. (LANG_HOOKS_EH_PERSONALITY): Likewise. cp/ * except.c (init_exception_processing): Do not set lang_eh_runtime_type. (choose_personality_routine): Do not set eh_personality_decl, set pragma_java_exceptions. * cp-lang.c (LANG_HOOKS_EH_RUNTIME_TYPE): Define. (LANG_HOOKS_EH_PERSONALITY): Likewise. (cp_eh_personality_decl): New. (cp_eh_personality): Likewise. * Make-lang.in (cp-lang.o): Add $(EXPR_H) and $(EXCEPT_H) dependencies. java/ * decl.c (do_nothing): Remove. (java_init_decl_processing): Do not set lang_eh_runtime_type. * Make-lang.in (lang.o): Add $(EXCEPT_H) dependency. * lang.c (java_eh_personality): New. (java_eh_personality_decl): Likewise. (LANG_HOOKS_EH_PERSONALITY): Define. ada/ * gcc-interface/misc.c (gnat_init_gcc_eh): Do not set lang_eh_runtime_type. (LANG_HOOKS_EH_PERSONALITY): Define. (gnat_eh_personality_decl): New. (gnat_eh_personality): Likewise. * Make-lang.in (misc.o): Add gt-ada-misc.h dependency. * config-lang.in (gtfiles): Add misc.c. fortran/ * f95-lang.c (gfc_maybe_initialize_eh): Do not init eh_personality_libfunc. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151676 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b5e73467127..b83c52f5370 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3505,6 +3505,13 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) cg_edge = cgraph_edge (id->dst_node, stmt); + /* Don't inline functions with different EH personalities. */ + if (DECL_FUNCTION_PERSONALITY (cg_edge->caller->decl) + && DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl) + && (DECL_FUNCTION_PERSONALITY (cg_edge->caller->decl) + != DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl))) + goto egress; + /* Don't try to inline functions that are not well-suited to inlining. */ if (!cgraph_inline_p (cg_edge, &reason)) @@ -3546,6 +3553,11 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) /* We will be inlining this callee. */ id->eh_region = lookup_stmt_eh_region (stmt); + /* Update the callers EH personality. */ + if (DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl)) + DECL_FUNCTION_PERSONALITY (cg_edge->caller->decl) + = DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl); + /* Split the block holding the GIMPLE_CALL. */ e = split_block (bb, stmt); bb = e->src; @@ -4730,6 +4742,7 @@ tree_function_versioning (tree old_decl, tree new_decl, DECL_ARTIFICIAL (new_decl) = 1; DECL_ABSTRACT_ORIGIN (new_decl) = DECL_ORIGIN (old_decl); + DECL_FUNCTION_PERSONALITY (new_decl) = DECL_FUNCTION_PERSONALITY (old_decl); /* Prepare the data structures for the tree copy. */ memset (&id, 0, sizeof (id)); @@ -5000,6 +5013,18 @@ tree_can_inline_p (struct cgraph_edge *e) caller = e->caller->decl; callee = e->callee->decl; + /* We cannot inline a function that uses a different EH personality + than the caller. */ + if (DECL_FUNCTION_PERSONALITY (caller) + && DECL_FUNCTION_PERSONALITY (callee) + && (DECL_FUNCTION_PERSONALITY (caller) + != DECL_FUNCTION_PERSONALITY (callee))) + { + e->inline_failed = CIF_UNSPECIFIED; + gimple_call_set_cannot_inline (e->call_stmt, true); + return false; + } + /* Allow the backend to decide if inlining is ok. */ if (!targetm.target_option.can_inline_p (caller, callee)) { -- cgit v1.2.1 From e38def9ca7953bb5611d08ce8617249516ba5a99 Mon Sep 17 00:00:00 2001 From: rth Date: Mon, 14 Sep 2009 19:18:58 +0000 Subject: Squash commit of EH in gimple git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151696 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 179 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 109 insertions(+), 70 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b83c52f5370..5ada378700f 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see MODIFY_EXPRs that store to a dedicated returned-value variable. The duplicated eh_region info of the copy will later be appended to the info for the caller; the eh_region info in copied throwing - statements and RESX_EXPRs is adjusted accordingly. + statements and RESX statements are adjusted accordingly. Cloning: (only in C++) We have one body for a con/de/structor, and multiple function decls, each with a unique parameter list. @@ -1105,12 +1105,6 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) TREE_BLOCK (*tp) = new_block; } - if (TREE_CODE (*tp) == RESX_EXPR && id->eh_region_offset) - TREE_OPERAND (*tp, 0) = - build_int_cst (NULL_TREE, - id->eh_region_offset - + TREE_INT_CST_LOW (TREE_OPERAND (*tp, 0))); - if (TREE_CODE (*tp) != OMP_CLAUSE) TREE_TYPE (*tp) = remap_type (TREE_TYPE (*tp), id); @@ -1150,6 +1144,35 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) return NULL_TREE; } +/* Helper for remap_gimple_stmt. Given an EH region number for the + source function, map that to the duplicate EH region number in + the destination function. */ + +static int +remap_eh_region_nr (int old_nr, copy_body_data *id) +{ + eh_region old_r, new_r; + void **slot; + + old_r = get_eh_region_from_number_fn (id->src_cfun, old_nr); + slot = pointer_map_contains (id->eh_map, old_r); + new_r = (eh_region) *slot; + + return new_r->index; +} + +/* Similar, but operate on INTEGER_CSTs. */ + +static tree +remap_eh_region_tree_nr (tree old_t_nr, copy_body_data *id) +{ + int old_nr, new_nr; + + old_nr = tree_low_cst (old_t_nr, 0); + new_nr = remap_eh_region_nr (old_nr, id); + + return build_int_cst (NULL, new_nr); +} /* Helper for copy_bb. Remap statement STMT using the inlining information in ID. Return the new statement copy. */ @@ -1339,9 +1362,59 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) VEC_safe_push (gimple, heap, id->debug_stmts, copy); return copy; } - else - /* Create a new deep copy of the statement. */ - copy = gimple_copy (stmt); + + /* Create a new deep copy of the statement. */ + copy = gimple_copy (stmt); + + /* Remap the region numbers for __builtin_eh_{pointer,filter}, + RESX and EH_DISPATCH. */ + if (id->eh_map) + switch (gimple_code (copy)) + { + case GIMPLE_CALL: + { + tree r, fndecl = gimple_call_fndecl (copy); + if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) + switch (DECL_FUNCTION_CODE (fndecl)) + { + case BUILT_IN_EH_COPY_VALUES: + r = gimple_call_arg (copy, 1); + r = remap_eh_region_tree_nr (r, id); + gimple_call_set_arg (copy, 1, r); + /* FALLTHRU */ + + case BUILT_IN_EH_POINTER: + case BUILT_IN_EH_FILTER: + r = gimple_call_arg (copy, 0); + r = remap_eh_region_tree_nr (r, id); + gimple_call_set_arg (copy, 0, r); + break; + + default: + break; + } + } + break; + + case GIMPLE_RESX: + { + int r = gimple_resx_region (copy); + r = remap_eh_region_nr (r, id); + gimple_resx_set_region (copy, r); + } + break; + + case GIMPLE_EH_DISPATCH: + { + int r = gimple_eh_dispatch_region (copy); + r = remap_eh_region_nr (r, id); + gimple_eh_dispatch_set_region (copy, r); + } + break; + + default: + break; + } } /* If STMT has a block defined, map it to the newly constructed @@ -1377,12 +1450,6 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) gimple_set_vuse (copy, NULL_TREE); } - /* We have to handle EH region remapping of GIMPLE_RESX specially because - the region number is not an operand. */ - if (gimple_code (stmt) == GIMPLE_RESX && id->eh_region_offset) - { - gimple_resx_set_region (copy, gimple_resx_region (stmt) + id->eh_region_offset); - } return copy; } @@ -1617,43 +1684,8 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, cfun->calls_setjmp = true; } - /* If you think we can abort here, you are wrong. - There is no region 0 in gimple. */ - gcc_assert (lookup_stmt_eh_region_fn (id->src_cfun, orig_stmt) != 0); - - if (stmt_could_throw_p (stmt) - /* When we are cloning for inlining, we are supposed to - construct a clone that calls precisely the same functions - as original. However IPA optimizers might've proved - earlier some function calls as non-trapping that might - render some basic blocks dead that might become - unreachable. - - We can't update SSA with unreachable blocks in CFG and thus - we prevent the scenario by preserving even the "dead" eh - edges until the point they are later removed by - fixup_cfg pass. */ - || (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES - && lookup_stmt_eh_region_fn (id->src_cfun, orig_stmt) > 0)) - { - int region = lookup_stmt_eh_region_fn (id->src_cfun, orig_stmt); - - /* Add an entry for the copied tree in the EH hashtable. - When cloning or versioning, use the hashtable in - cfun, and just copy the EH number. When inlining, use the - hashtable in the caller, and adjust the region number. */ - if (region > 0) - add_stmt_to_eh_region (stmt, region + id->eh_region_offset); - - /* If this tree doesn't have a region associated with it, - and there is a "current region," - then associate this tree with the current region - and add edges associated with this region. */ - if (lookup_stmt_eh_region_fn (id->src_cfun, orig_stmt) <= 0 - && id->eh_region > 0 - && stmt_could_throw_p (stmt)) - add_stmt_to_eh_region (stmt, id->eh_region); - } + maybe_duplicate_eh_stmt_fn (cfun, stmt, id->src_cfun, orig_stmt, + id->eh_map, id->eh_lp_nr); if (gimple_in_ssa_p (cfun) && !is_gimple_debug (stmt)) { @@ -1822,7 +1854,9 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) } } - if (can_throw) + if (gimple_code (copy_stmt) == GIMPLE_EH_DISPATCH) + make_eh_dispatch_edges (copy_stmt); + else if (can_throw) make_eh_edges (copy_stmt); if (nonlocal_goto) @@ -2025,11 +2059,8 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, /* Duplicate any exception-handling regions. */ if (cfun->eh) - { - id->eh_region_offset - = duplicate_eh_regions (cfun_to_copy, remap_decl_1, id, - 0, id->eh_region); - } + id->eh_map = duplicate_eh_regions (cfun_to_copy, NULL, id->eh_lp_nr, + remap_decl_1, id); /* Use aux pointers to map the original blocks to copy. */ FOR_EACH_BB_FN (bb, cfun_to_copy) @@ -2062,6 +2093,12 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, entry_block_map->aux = NULL; exit_block_map->aux = NULL; + if (id->eh_map) + { + pointer_map_destroy (id->eh_map); + id->eh_map = NULL; + } + return new_fndecl; } @@ -3190,14 +3227,6 @@ estimate_num_insns (gimple stmt, eni_weights *weights) lhs = gimple_assign_lhs (stmt); rhs = gimple_assign_rhs1 (stmt); - /* EH magic stuff is most probably going to be optimized out. - We rarely really need to save EH info for unwinding - nested exceptions. */ - if (TREE_CODE (lhs) == FILTER_EXPR - || TREE_CODE (lhs) == EXC_PTR_EXPR - || TREE_CODE (rhs) == FILTER_EXPR - || TREE_CODE (rhs) == EXC_PTR_EXPR) - return 0; if (is_gimple_reg (lhs)) cost = 0; else @@ -3308,9 +3337,19 @@ estimate_num_insns (gimple stmt, eni_weights *weights) return 0; case GIMPLE_ASM: - case GIMPLE_RESX: return 1; + case GIMPLE_RESX: + /* This is either going to be an external function call with one + argument, or two register copy statements plus a goto. */ + return 2; + + case GIMPLE_EH_DISPATCH: + /* ??? This is going to turn into a switch statement. Ideally + we'd have a look at the eh region and estimate the number of + edges involved. */ + return 10; + case GIMPLE_BIND: return estimate_num_insns_seq (gimple_bind_body (stmt), weights); @@ -3551,7 +3590,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) #endif /* We will be inlining this callee. */ - id->eh_region = lookup_stmt_eh_region (stmt); + id->eh_lp_nr = lookup_stmt_eh_lp (stmt); /* Update the callers EH personality. */ if (DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl)) @@ -4935,7 +4974,7 @@ maybe_inline_call_in_expr (tree exp) id.do_not_unshare = true; /* We're not inside any EH region. */ - id.eh_region = -1; + id.eh_lp_nr = 0; t = copy_tree_body (&id); pointer_map_destroy (decl_map); -- cgit v1.2.1 From e1f1071ca8bd74cc6fa80e5cc024360ced018d9a Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 17 Sep 2009 11:11:58 +0000 Subject: PR middle-end/41347 * tree.c (build_type_attribute_qual_variant): Export. * tree.h (build_type_attribute_qual_variant): Declare. * tree-inline.c (remap_type_1): Use it to build variants with the original qualifiers and attributes. testsuite/ * gfortran.dg/pr41347.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151799 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 5ada378700f..feb749985c2 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -342,6 +342,10 @@ remap_type_1 (tree type, copy_body_data *id) new_tree = build_pointer_type_for_mode (remap_type (TREE_TYPE (type), id), TYPE_MODE (type), TYPE_REF_CAN_ALIAS_ALL (type)); + if (TYPE_ATTRIBUTES (type) || TYPE_QUALS (type)) + new_tree = build_type_attribute_qual_variant (new_tree, + TYPE_ATTRIBUTES (type), + TYPE_QUALS (type)); insert_decl_map (id, type, new_tree); return new_tree; } @@ -350,6 +354,10 @@ remap_type_1 (tree type, copy_body_data *id) new_tree = build_reference_type_for_mode (remap_type (TREE_TYPE (type), id), TYPE_MODE (type), TYPE_REF_CAN_ALIAS_ALL (type)); + if (TYPE_ATTRIBUTES (type) || TYPE_QUALS (type)) + new_tree = build_type_attribute_qual_variant (new_tree, + TYPE_ATTRIBUTES (type), + TYPE_QUALS (type)); insert_decl_map (id, type, new_tree); return new_tree; } -- cgit v1.2.1 From a65c4d644bc63c7e9ed0df60898aac5aff8cc60c Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 28 Sep 2009 12:54:23 +0000 Subject: * builtins.c (interclass_mathfn_icode): New helper. (expand_builtin_interclass_mathfn): Use it here, and split folding into ... (fold_builtin_interclass_mathfn): ... this new folder. (build_call_nofold_loc): New static helper. (build_call_nofold): New wrapper macro for above. (expand_builtin_int_roundingfn): Use it instead of build_call_expr. (expand_builtin_pow): Ditto. (expand_builtin_memset_args): Ditto. (expand_builtin_printf): Ditto. (expand_builtin_fprintf): Ditto. (expand_builtin_sprintf): Ditto. (expand_builtin_memory_chk): Ditto. (expand_builtin_mempcpy_args): Ditto and don't call folders. (expand_builtin_stpcpy): Ditto. (expand_builtin_strcmp): Ditto. (expand_builtin_strncmp): Ditto. (expand_builtin_strcpy): Remove FNDECL and MODE arguments. (expand_builtin_strcpy_args): Don't call folders. (expand_builtin_memcmp): Ditto. (expand_builtin_strncpy): Ditto, and use target. (expand_builtin_memcpy): Ditto. (expand_builtin_strstr, expand_builtin_strchr, expand_builtin_strrchr, expand_builtin_strpbrk, expand_builtin_memmove, expand_builtin_memmove_args, expand_builtin_bcopy, expand_builtin_memchr, expand_builtin_strcat, expand_builtin_strncat, expand_builtin_strspn, expand_builtin_strcspn, expand_builtin_fputs): Remove these. (expand_builtin): Don't call the above, change calls to other expanders that changed prototype. (fold_builtin_stpcpy): New folder split out from expand_builtin_stpcpy. (fold_builtin_1 ): Call fold_builtin_interclass_mathfn. (fold_builtin_2 ): Call fold_builtin_stpcpy. (fold_builtin_strcat): Add folding split from expand_builtin_strcat. * fold-const.c (fold_binary_loc ): Add !exp != 0 -> !exp. * passes.c (init_optimization_passes): Move pass_fold_builtins after last phiopt pass. * tree-inline.c (fold_marked_statements): When folding builtins iterate over all instruction potentially generated. * tree-ssa-ccp.c (gimplify_and_update_call_from_tree): Declare earlier. (fold_gimple_call): Use it to always fold calls (into potentially multiple instructions). * tree-ssa-dom.c (optimize_stmt): Resolve __builtin_constant_p calls into zero at this time. * tree-ssa-propagate.c (substitute_and_fold): Ignore multiple statements generated by builtin folding. testsuite/ * gcc.dg/builtins-44.c: Use __builtin_isinf_sign when checking for sign of -Inf. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152236 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index feb749985c2..6e1ea39aa92 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3873,7 +3873,48 @@ fold_marked_statements (int first, struct pointer_set_t *statements) gimple old_stmt = gsi_stmt (gsi); tree old_decl = is_gimple_call (old_stmt) ? gimple_call_fndecl (old_stmt) : 0; - if (fold_stmt (&gsi)) + if (old_decl && DECL_BUILT_IN (old_decl)) + { + /* Folding builtins can create multiple instructions, + we need to look at all of them. */ + gimple_stmt_iterator i2 = gsi; + gsi_prev (&i2); + if (fold_stmt (&gsi)) + { + gimple new_stmt; + if (gsi_end_p (i2)) + i2 = gsi_start_bb (BASIC_BLOCK (first)); + else + gsi_next (&i2); + while (1) + { + new_stmt = gsi_stmt (i2); + update_stmt (new_stmt); + cgraph_update_edges_for_call_stmt (old_stmt, old_decl, + new_stmt); + + if (new_stmt == gsi_stmt (gsi)) + { + /* It is okay to check only for the very last + of these statements. If it is a throwing + statement nothing will change. If it isn't + this can remove EH edges. If that weren't + correct then because some intermediate stmts + throw, but not the last one. That would mean + we'd have to split the block, which we can't + here and we'd loose anyway. And as builtins + probably never throw, this all + is mood anyway. */ + if (maybe_clean_or_replace_eh_stmt (old_stmt, + new_stmt)) + gimple_purge_dead_eh_edges (BASIC_BLOCK (first)); + break; + } + gsi_next (&i2); + } + } + } + else if (fold_stmt (&gsi)) { /* Re-read the statement from GSI as fold_stmt() may have changed it. */ @@ -3882,7 +3923,8 @@ fold_marked_statements (int first, struct pointer_set_t *statements) if (is_gimple_call (old_stmt) || is_gimple_call (new_stmt)) - cgraph_update_edges_for_call_stmt (old_stmt, old_decl, new_stmt); + cgraph_update_edges_for_call_stmt (old_stmt, old_decl, + new_stmt); if (maybe_clean_or_replace_eh_stmt (old_stmt, new_stmt)) gimple_purge_dead_eh_edges (BASIC_BLOCK (first)); -- cgit v1.2.1 From 7bfefa9d2c82e804ef4e59772f4060ac325bf99a Mon Sep 17 00:00:00 2001 From: dnovillo Date: Sat, 3 Oct 2009 21:10:11 +0000 Subject: Merge lto branch into trunk. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152434 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 6e1ea39aa92..e38da6d5bde 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1632,6 +1632,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, edge = cgraph_edge (id->src_node, orig_stmt); if (edge) edge = cgraph_clone_edge (edge, id->dst_node, stmt, + gimple_uid (stmt), REG_BR_PROB_BASE, 1, edge->frequency, true); break; @@ -5119,13 +5120,16 @@ tree_can_inline_p (struct cgraph_edge *e) { e->inline_failed = CIF_TARGET_OPTION_MISMATCH; gimple_call_set_cannot_inline (e->call_stmt, true); + e->call_stmt_cannot_inline_p = true; return false; } - if (!gimple_check_call_args (e->call_stmt)) + if (e->call_stmt + && !gimple_check_call_args (e->call_stmt)) { e->inline_failed = CIF_MISMATCHED_ARGUMENTS; gimple_call_set_cannot_inline (e->call_stmt, true); + e->call_stmt_cannot_inline_p = true; return false; } -- cgit v1.2.1 From 1ca8efe41dd2817f23f707140062ea386adbdf32 Mon Sep 17 00:00:00 2001 From: pinskia Date: Mon, 5 Oct 2009 17:46:35 +0000 Subject: 2009-10-05 Andrew Pinski PR tree-opt/40992 * final.c (asm_str_count): Split out from asm_insn_count. * rtl.h (asm_str_count): New prototype. * tree-inline (estimate_num_insns) : Call asm_str_count. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152458 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e38da6d5bde..91ed023312a 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3346,7 +3346,7 @@ estimate_num_insns (gimple stmt, eni_weights *weights) return 0; case GIMPLE_ASM: - return 1; + return asm_str_count (gimple_asm_string (stmt)); case GIMPLE_RESX: /* This is either going to be an external function call with one -- cgit v1.2.1 From bd1a81f7e1665d2e33cc824dd05dd7988da9f1a8 Mon Sep 17 00:00:00 2001 From: uweigand Date: Mon, 26 Oct 2009 21:55:59 +0000 Subject: 2009-10-26 Ben Elliston Michael Meissner Ulrich Weigand * doc/extend.texi (Named Address Spaces): New section. * coretypes.h (addr_space_t): New type. (ADDR_SPACE_GENERIC): New define. (ADDR_SPACE_GENERIC_P): New macro. * doc/tm.texi (Named Address Spaces): New section. (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Document. (TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS): Document. (TARGET_ADDR_SPACE_SUBSET_P): Document. (TARGET_ADDR_SPACE_CONVERT): Document. * target.h (struct gcc_target): Add addr_space substructure. * target-def.h (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Define. (TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS): Likewise. (TARGET_ADDR_SPACE_SUBSET_P): Likewise. (TARGET_ADDR_SPACE_CONVERT): Likewise. (TARGET_ADDR_SPACE_HOOKS): Likewise. (TARGET_INITIALIZER): Initialize addr_space hooks. * targhooks.c (default_addr_space_legitimate_address_p): New function. (default_addr_space_legitimize_address): Likewise. (default_addr_space_subset_p): Likewise. (default_addr_space_convert): Likewise. * targhooks.h (default_addr_space_legitimate_address_p): Add prototype. (default_addr_space_legitimize_address): Likewise. (default_addr_space_subset_p): Likewise. (default_addr_space_convert): Likewise. * doc/rtl.texi (MEM_ADDR_SPACE): Document. * rtl.h (mem_attrs): Add ADDRSPACE memory attribute. (MEM_ADDR_SPACE): New macro. * emit-rtl.c (get_mem_attrs): Add ADDRSPACE argument and set address space memory attribute. (mem_attrs_htab_hash): Handle address space memory attribute. (mem_attrs_htab_eq): Likewise. (set_mem_attributes_minus_bitpos): Likewise. (set_mem_alias_set): Likewise. (set_mem_align): Likewise. (set_mem_expr): Likewise. (set_mem_offset): Likewise. (set_mem_size): Likewise. (adjust_address_1): Likewise. (offset_address): Likewise. (widen_memoy_address): Likewise. (get_spill_slot_decl): Likewise. (set_mem_attrs_for_spill): Likewise. (set_mem_addr_space): New function. * emit-rtl.h (set_mem_addr_space): Add prototype. * print-rtl.c (print_rtx): Print address space memory attribute. * expr.c (expand_assignment): Set address space memory attribute of generated MEM RTXes as appropriate. (expand_expr_real_1): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * tree-ssa-loop-ivopts.c (produce_memory_decl_rtl): Likewise. * tree.h (struct tree_base): Add address_space bitfield. Reduce size of "spare" bitfield. (TYPE_ADDR_SPACE): New macro. (ENCODE_QUAL_ADDR_SPACE): Likewise. (DECODE_QUAL_ADDR_SPACE): Likewise. (CLEAR_QUAL_ADDR_SPACE): Likewise. (KEEP_QUAL_ADDR_SPACE): Likewise. (TYPE_QUALS): Encode type address space. (TYPE_QUALS_NO_ADDR_SPACE): New macro. * tree.c (set_type_quals): Set type address space. (build_array_type): Inherit array address space from element type. * print-tree.c (print_node_brief): Print type address space. (print_node): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * explow.c (memory_address): Rename to ... (memory_address_addr_space): ... this. Add ADDRSPACE argument. Use address-space aware variants of memory address routines. * recog.c (memory_address_p): Rename to ... (memory_address_addr_space_p): ... this. Add ADDSPACE argument. Use address-space aware variants of memory address routines. (offsettable_address_p): Rename to ... (offsettable_address_addr_space_p): ... this. Add ADDRSPACE argument. Use address-space aware variants of memory address routines. * reload.c (strict_memory_address_p): Rename to ... (strict_memory_address_addr_space_p): ... this. Add ADDSPACE argument. Use address-space aware variants of memory address routines. (maybe_memory_address_p): Rename to ... (maybe_memory_address_addr_space_p): ... this. Add ADDSPACE argument. Use address-space aware variants of memory address routines. * expr.h (memory_address_addr_space): Add prototype. (memory_address): Define as macro. * recog.h (memory_address_addr_space_p): Add prototype. (memory_address_p): Define as macro. (offsettable_address_addr_space_p): Add prototype. (offsettable_address_p): Define as macro. (strict_memory_address_addr_space_p): Add prototype. (strict_memory_address_p): Define as macro. * combine.c (find_split_point): Use address-space aware variants of memory address routines. * emit-rtl.c (operand_subword): Likewise. (change_address_1): Likewise. (adjust_address_1): Likewise. (offset_address): Likewise. * expr.c (emit_move_insn): Likewise. (expand_assignment): Likewise. (expand_expr_real_1): Likewise. * recog.c (verify_changes): Likewise. (general_operand): Likewise. (offsettable_memref_p): Likewise. (offsettable_nonstrict_memref_p): Likewise. (constrain_operands): Likewise. * reload.c (get_secondary_mem): Likewise. (find_reloads_toplev): Likewise. (find_reloads_address): Likewise. (find_reloads_subreg_address): Likewise. * reload1.c (reload): Likewise. * rtlhooks.c (gen_lowpart_if_possible): Likewise. * rtl.h (address_cost): Add ADDRSPACE argument. * rtlanal.c (address_cost): Add ADDRSPACE argument. Use address-space aware variant of memory address routines. * loop-invariant.c (create_new_invariant): Update address_cost call. * tree-ssa-loop-ivopts.c (computation_cost): Likewise. * fwprop.c (should_replace_address): Add ADDRSPACE argument. Use address-space aware variant of memory address routines. (propagate_rtx_1): Update call to should_replace_address. * tree-flow.h (multiplier_allowed_in_address_p): Add ADDRSPACE argument. * tree-ssa-loop-ivopts.c (multiplier_allowed_in_address_p): Add ADDRSPACE argument. Use per-address-space instead of global cache. Use address-space aware variant of memory address routines. (get_address_cost): Likewise. (get_computation_cost_at): Update calls. * tree-ssa-address.c (valid_mem_ref_p): Add ADDRSPACE argument. Use address-space aware variant of memory address routines. (create_mem_ref_raw): Update call to valid_mem_ref_p. (most_expensive_mult_to_index): Update call to multiplier_allowed_in_address_p. * dwarf2out.c (modified_type_die): Output DW_AT_address_class attribute to indicate named address spaces. * varasm.c (get_variable_section): DECLs in named address spaces cannot be "common". * reload.c (find_reloads_address): Do not use LEGITIMIZE_RELOAD_ADDRESS for addresses in a non-generic address space. * expr.c (emit_block_move_hints): Do not use libcalls for memory in non-generic address spaces. (clear_storage_hints): Likewise. (expand_assignment): Likewise. * fold-const.c (operand_equal_p): Expressions refering to different address spaces are not equivalent. * rtl.c (rtx_equal_p_cb): MEMs refering to different address spaces are not equivalent. (rtx_equal_p): Likewise. * cse.c (exp_equiv_p): Likewise. * jump.c (rtx_renumbered_equal_p): Likewise. * reload.c (operands_match_p): Likewise. * alias.c (nonoverlapping_memrefs_p): MEMs refering to different address spaces may alias. (true_dependence): Likewise. (canon_true_dependence): Likewise. (write_dependence_p): Likewise. * dse.c (canon_address): Handle named address spaces. * ifcvt.c (noce_try_cmove_arith): Likewise. * tree.def (ADDR_SPACE_CONVERT_EXPR): New tree code. * expr.c (expand_expr_real_2): Expand ADDR_SPACE_CONVERT_EXPR. * convert.c (convert_to_pointer): Generate ADDR_SPACE_CONVERT_EXPR to handle conversions between different address spaces. * fold-const.c (fold_convert_loc): Likewise. (fold_unary_loc): Handle ADDR_SPACE_CONVERT_EXPR. * tree-pretty-print.c (dump_generic_node): Likewise. * gimple-pretty-print.c (dump_unary_rhs): Likewise. * tree-cfg.c (verify_gimple_assign_unary): Likewise. * tree-inline.c (estimate_operator_cost): Likewise. * tree-ssa.c (useless_type_conversion_p): Conversions between pointers to different address spaces are not useless. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153572 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 91ed023312a..f0ed4ba73a7 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3083,6 +3083,7 @@ estimate_operator_cost (enum tree_code code, eni_weights *weights, case MINUS_EXPR: case MULT_EXPR: + case ADDR_SPACE_CONVERT_EXPR: case FIXED_CONVERT_EXPR: case FIX_TRUNC_EXPR: -- cgit v1.2.1 From 6d1cc52ccc8ccbb8d83ceb218c2e24ee9bbd2c4b Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 16 Nov 2009 13:26:40 +0000 Subject: * cgraph.c (cgraph_release_function_body): Update use of ipa_transforms_to_apply. (cgraph_remove_node): Remove ipa_transforms_to_apply. * cgraph.h (struct cgraph_node): Add ipa_transforms_to_apply. * cgraphunit.c (save_inline_function_body): Clear ipa_transforms for copied body. (cgraph_materialize_clone): Remove original if dead. * lto-streamer-in.c (lto_read_body): Remove FIXME and ipa_transforms_to_apply hack. * function.h (struct function): Add ipa_transforms_to_apply. * ipa.c (cgraph_remove_unreachable_nodes): Handle dead clone originals. * tree-inline.c (copy_bb): Update sanity check. (initialize_cfun): Do not copy ipa_transforms_to_apply. (expand_call_inline): remove dead clone originals. (tree_function_versioning): Merge transformation queues. * passes.c (add_ipa_transform_pass): Remove. (execute_one_ipa_transform_pass): Update ipa_transforms_to_apply tracking. (execute_all_ipa_transforms): Update. (execute_one_pass): Update. * lto.c (read_cgraph_and_symbols): Set also ipa_transforms_to_apply. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154200 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f0ed4ba73a7..629ccfb524f 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1665,10 +1665,12 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* We have missing edge in the callgraph. This can happen when previous inlining turned an indirect call into a - direct call by constant propagating arguments. In all + direct call by constant propagating arguments or we are + producing dead clone (for further clonning). In all other cases we hit a bug (incorrect node sharing is the most common reason for missing edges). */ - gcc_assert (dest->needed || !dest->analyzed); + gcc_assert (dest->needed || !dest->analyzed + || !id->src_node->analyzed); if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) cgraph_create_edge_including_clones (id->dst_node, dest, stmt, bb->count, @@ -1983,9 +1985,6 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count, cfun->function_end_locus = src_cfun->function_end_locus; cfun->curr_properties = src_cfun->curr_properties; cfun->last_verified = src_cfun->last_verified; - if (src_cfun->ipa_transforms_to_apply) - cfun->ipa_transforms_to_apply = VEC_copy (ipa_opt_pass, heap, - src_cfun->ipa_transforms_to_apply); cfun->va_list_gpr_size = src_cfun->va_list_gpr_size; cfun->va_list_fpr_size = src_cfun->va_list_fpr_size; cfun->function_frequency = src_cfun->function_frequency; @@ -3822,6 +3821,10 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) (*debug_hooks->outlining_inline_function) (cg_edge->callee->decl); /* Update callgraph if needed. */ + if (cg_edge->callee->clone_of + && !cg_edge->callee->clone_of->next_sibling_clone + && !cg_edge->callee->analyzed) + cgraph_remove_node (cg_edge->callee); cgraph_remove_node (cg_edge->callee); id->block = NULL_TREE; @@ -4848,6 +4851,19 @@ tree_function_versioning (tree old_decl, tree new_decl, id.src_node = old_version_node; id.dst_node = new_version_node; id.src_cfun = DECL_STRUCT_FUNCTION (old_decl); + if (id.src_node->ipa_transforms_to_apply) + { + VEC(ipa_opt_pass,heap) * old_transforms_to_apply = id.dst_node->ipa_transforms_to_apply; + unsigned int i; + + id.dst_node->ipa_transforms_to_apply = VEC_copy (ipa_opt_pass, heap, + id.src_node->ipa_transforms_to_apply); + for (i = 0; i < VEC_length (ipa_opt_pass, old_transforms_to_apply); i++) + VEC_safe_push (ipa_opt_pass, heap, id.dst_node->ipa_transforms_to_apply, + VEC_index (ipa_opt_pass, + old_transforms_to_apply, + i)); + } id.copy_decl = copy_decl_no_change; id.transform_call_graph_edges -- cgit v1.2.1 From e2d3f42272e712ce0bda8583066fdf858041ce77 Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 16 Nov 2009 16:06:29 +0000 Subject: * cgraphbuild.c (compute_call_stmt_bb_frequency): Use proper ENTRY_BLOCK_PTR. * cgraph.c (cgraph_clone_edge): Avoid freq_scale 0 to completely zero out all callees. * cgraphunit.c (verify_cgraph_node): Verify cgraph nodes for frequency and count match. * ipa-inline.c (update_noncloned_frequencies): New function. (cgraph_clone_inlined_nodes): Use it. * tree-inline.c (copy_bb): Fix frequency scaling; output diagnostic on frequency mismatches to dump file. (initialize_cfun): Do not scale frequency; fix count scaling; initialize entry and exit block frequencies; copy profile info. (copy_cfg_body): Use frequency_scale as argument; fix count scaling. (copy_body): Use frequency_scale as argument. (expand_call_inline): Compute frequency scale and output diagnostic to dump file. (delete_unreachable_blocks_update_callgrah): Remove checking that has to be done after edge redirection. (tree_function_versioning): Update initialize_cfun and copy_body call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154205 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 127 ++++++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 65 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 629ccfb524f..34a8e9d8d07 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1472,6 +1472,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, gimple_stmt_iterator gsi, copy_gsi, seq_gsi; basic_block copy_basic_block; tree decl; + gcov_type freq; /* create_basic_block() will append every new block to basic_block_info automatically. */ @@ -1481,11 +1482,12 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* We are going to rebuild frequencies from scratch. These values have just small importance to drive canonicalize_loop_headers. */ - copy_basic_block->frequency = ((gcov_type)bb->frequency - * frequency_scale / REG_BR_PROB_BASE); + freq = ((gcov_type)bb->frequency * frequency_scale / REG_BR_PROB_BASE); - if (copy_basic_block->frequency > BB_FREQ_MAX) - copy_basic_block->frequency = BB_FREQ_MAX; + /* We recompute frequencies after inlining, so this is quite safe. */ + if (freq > BB_FREQ_MAX) + freq = BB_FREQ_MAX; + copy_basic_block->frequency = freq; copy_gsi = gsi_start_bb (copy_basic_block); @@ -1631,10 +1633,34 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, case CB_CGE_DUPLICATE: edge = cgraph_edge (id->src_node, orig_stmt); if (edge) - edge = cgraph_clone_edge (edge, id->dst_node, stmt, - gimple_uid (stmt), - REG_BR_PROB_BASE, 1, - edge->frequency, true); + { + int edge_freq = edge->frequency; + edge = cgraph_clone_edge (edge, id->dst_node, stmt, + gimple_uid (stmt), + REG_BR_PROB_BASE, CGRAPH_FREQ_BASE, + edge->frequency, true); + /* We could also just rescale the frequency, but + doing so would introduce roundoff errors and make + verifier unhappy. */ + edge->frequency + = compute_call_stmt_bb_frequency (id->dst_node->decl, + copy_basic_block); + if (dump_file + && profile_status_for_function (cfun) != PROFILE_ABSENT + && (edge_freq > edge->frequency + 10 + || edge_freq < edge->frequency - 10)) + { + fprintf (dump_file, "Edge frequency estimated by " + "cgraph %i diverge from inliner's estimate %i\n", + edge_freq, + edge->frequency); + fprintf (dump_file, + "Orig bb: %i, orig bb freq %i, new bb freq %i\n", + bb->index, + bb->frequency, + copy_basic_block->frequency); + } + } break; case CB_CGE_MOVE_CLONES: @@ -1674,7 +1700,8 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) cgraph_create_edge_including_clones (id->dst_node, dest, stmt, bb->count, - compute_call_stmt_bb_frequency (id->dst_node->decl, bb), + compute_call_stmt_bb_frequency (id->dst_node->decl, + copy_basic_block), bb->loop_depth, CIF_ORIGINALLY_INDIRECT_CALL); else cgraph_create_edge (id->dst_node, dest, stmt, @@ -1948,24 +1975,16 @@ remap_decl_1 (tree decl, void *data) NEW_FNDECL to be build. CALLEE_FNDECL is the original */ static void -initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count, - int frequency) +initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count) { struct function *src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl); - gcov_type count_scale, frequency_scale; + gcov_type count_scale; if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count) count_scale = (REG_BR_PROB_BASE * count / ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count); else - count_scale = 1; - - if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency) - frequency_scale = (REG_BR_PROB_BASE * frequency - / - ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency); - else - frequency_scale = count_scale; + count_scale = REG_BR_PROB_BASE; /* Register specific tree functions. */ gimple_register_cfg_hooks (); @@ -1998,18 +2017,17 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count, init_empty_tree_cfg (); + profile_status_for_function (cfun) = profile_status_for_function (src_cfun); ENTRY_BLOCK_PTR->count = (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count * count_scale / REG_BR_PROB_BASE); - ENTRY_BLOCK_PTR->frequency = - (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency * - frequency_scale / REG_BR_PROB_BASE); + ENTRY_BLOCK_PTR->frequency + = ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency; EXIT_BLOCK_PTR->count = (EXIT_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count * count_scale / REG_BR_PROB_BASE); EXIT_BLOCK_PTR->frequency = - (EXIT_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency * - frequency_scale / REG_BR_PROB_BASE); + EXIT_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency; if (src_cfun->eh) init_eh_for_function (); @@ -2026,7 +2044,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count, another function. Walks FN via CFG, returns new fndecl. */ static tree -copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, +copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, basic_block entry_block_map, basic_block exit_block_map) { tree callee_fndecl = id->src_fn; @@ -2035,21 +2053,14 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, struct function *cfun_to_copy; basic_block bb; tree new_fndecl = NULL; - gcov_type count_scale, frequency_scale; + gcov_type count_scale; int last; if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count) count_scale = (REG_BR_PROB_BASE * count / ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count); else - count_scale = 1; - - if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency) - frequency_scale = (REG_BR_PROB_BASE * frequency - / - ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency); - else - frequency_scale = count_scale; + count_scale = REG_BR_PROB_BASE; /* Register specific tree functions. */ gimple_register_cfg_hooks (); @@ -2204,7 +2215,7 @@ copy_tree_body (copy_body_data *id) another function. */ static tree -copy_body (copy_body_data *id, gcov_type count, int frequency, +copy_body (copy_body_data *id, gcov_type count, int frequency_scale, basic_block entry_block_map, basic_block exit_block_map) { tree fndecl = id->src_fn; @@ -2212,7 +2223,7 @@ copy_body (copy_body_data *id, gcov_type count, int frequency, /* If this body has a CFG, walk CFG and copy. */ gcc_assert (ENTRY_BLOCK_PTR_FOR_FUNCTION (DECL_STRUCT_FUNCTION (fndecl))); - body = copy_cfg_body (id, count, frequency, entry_block_map, exit_block_map); + body = copy_cfg_body (id, count, frequency_scale, entry_block_map, exit_block_map); copy_debug_stmts (id); return body; @@ -3732,12 +3743,23 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) cfun->local_decls); } + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Inlining "); + print_generic_expr (dump_file, id->src_fn, 0); + fprintf (dump_file, " to "); + print_generic_expr (dump_file, id->dst_fn, 0); + fprintf (dump_file, " with frequency %i\n", cg_edge->frequency); + } + /* This is it. Duplicate the callee body. Assume callee is pre-gimplified. Note that we must not alter the caller function in any way before this point, as this CALL_EXPR may be a self-referential call; if we're calling ourselves, we need to duplicate our body before altering anything. */ - copy_body (id, bb->count, bb->frequency, bb, return_block); + copy_body (id, bb->count, + cg_edge->frequency * REG_BR_PROB_BASE / CGRAPH_FREQ_BASE, + bb, return_block); /* Reset the escaped and callused solutions. */ if (cfun->gimple_df) @@ -4732,30 +4754,6 @@ delete_unreachable_blocks_update_callgraph (copy_body_data *id) if (changed) tidy_fallthru_edges (); -#ifdef ENABLE_CHECKING0 - verify_cgraph_node (id->dst_node); - if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES - && id->dst_node->clones) - { - struct cgraph_node *node; - for (node = id->dst_node->clones; node != id->dst_node;) - { - verify_cgraph_node (node); - - if (node->clones) - node = node->clones; - else if (node->next_sibling_clone) - node = node->next_sibling_clone; - else - { - while (node != id->dst_node && !node->next_sibling_clone) - node = node->clone_of; - if (node != id->dst_node) - node = node->next_sibling_clone; - } - } - } -#endif return changed; } @@ -4876,8 +4874,7 @@ tree_function_versioning (tree old_decl, tree new_decl, old_entry_block = ENTRY_BLOCK_PTR_FOR_FUNCTION (DECL_STRUCT_FUNCTION (old_decl)); initialize_cfun (new_decl, old_decl, - old_entry_block->count, - old_entry_block->frequency); + old_entry_block->count); push_cfun (DECL_STRUCT_FUNCTION (new_decl)); /* Copy the function's static chain. */ @@ -4947,7 +4944,7 @@ tree_function_versioning (tree old_decl, tree new_decl, } /* Copy the Function's body. */ - copy_body (&id, old_entry_block->count, old_entry_block->frequency, + copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR); if (DECL_RESULT (old_decl) != NULL_TREE) -- cgit v1.2.1 From 48e1416a24d50cacbb2a5e06a9ee61dd8cbee313 Mon Sep 17 00:00:00 2001 From: hjl Date: Wed, 25 Nov 2009 10:55:54 +0000 Subject: Remove trailing white spaces. 2009-11-25 H.J. Lu * alias.c: Remove trailing white spaces. * alloc-pool.c: Likewise. * alloc-pool.h: Likewise. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * basic-block.h: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * builtins.c: Likewise. * builtins.def: Likewise. * c-common.c: Likewise. * c-common.h: Likewise. * c-cppbuiltin.c: Likewise. * c-decl.c: Likewise. * c-format.c: Likewise. * c-lex.c: Likewise. * c-omp.c: Likewise. * c-opts.c: Likewise. * c-parser.c: Likewise. * c-pretty-print.c: Likewise. * c-tree.h: Likewise. * c-typeck.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfghooks.h: Likewise. * cfglayout.c: Likewise. * cfgloop.c: Likewise. * cfgloop.h: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphbuild.c: Likewise. * cgraphunit.c: Likewise. * cif-code.def: Likewise. * collect2.c: Likewise. * combine.c: Likewise. * convert.c: Likewise. * coverage.c: Likewise. * crtstuff.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dbgcnt.c: Likewise. * dbgcnt.def: Likewise. * dbgcnt.h: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * ddg.c: Likewise. * ddg.h: Likewise. * defaults.h: Likewise. * df-byte-scan.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * df.h: Likewise. * dfp.c: Likewise. * diagnostic.c: Likewise. * diagnostic.h: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * double-int.c: Likewise. * double-int.h: Likewise. * dse.c: Likewise. * dwarf2asm.c: Likewise. * dwarf2asm.h: Likewise. * dwarf2out.c: Likewise. * ebitmap.c: Likewise. * ebitmap.h: Likewise. * emit-rtl.c: Likewise. * et-forest.c: Likewise. * except.c: Likewise. * except.h: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * expr.h: Likewise. * final.c: Likewise. * flags.h: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * function.h: Likewise. * fwprop.c: Likewise. * gcc.c: Likewise. * gcov-dump.c: Likewise. * gcov-io.c: Likewise. * gcov-io.h: Likewise. * gcov.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * genattrtab.c: Likewise. * genautomata.c: Likewise. * genchecksum.c: Likewise. * genconfig.c: Likewise. * genflags.c: Likewise. * gengtype-parse.c: Likewise. * gengtype.c: Likewise. * gengtype.h: Likewise. * genmddeps.c: Likewise. * genmodes.c: Likewise. * genopinit.c: Likewise. * genpreds.c: Likewise. * gensupport.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * ggc-zone.c: Likewise. * ggc.h: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimple.def: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * graphds.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * gthr-nks.h: Likewise. * gthr-posix.c: Likewise. * gthr-posix.h: Likewise. * gthr-posix95.h: Likewise. * gthr-single.h: Likewise. * gthr-tpf.h: Likewise. * gthr-vxworks.h: Likewise. * gthr.h: Likewise. * haifa-sched.c: Likewise. * hard-reg-set.h: Likewise. * hooks.c: Likewise. * hooks.h: Likewise. * hosthooks.h: Likewise. * hwint.h: Likewise. * ifcvt.c: Likewise. * incpath.c: Likewise. * init-regs.c: Likewise. * integrate.c: Likewise. * ipa-cp.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-reference.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-struct-reorg.h: Likewise. * ipa-type-escape.c: Likewise. * ipa-type-escape.h: Likewise. * ipa-utils.c: Likewise. * ipa-utils.h: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-emit.c: Likewise. * ira-int.h: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * jump.c: Likewise. * lambda-code.c: Likewise. * lambda-mat.c: Likewise. * lambda-trans.c: Likewise. * lambda.h: Likewise. * langhooks.c: Likewise. * lcm.c: Likewise. * libgcov.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-init.c: Likewise. * loop-invariant.c: Likewise. * loop-iv.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-streamer.h: Likewise. * lto-symtab.c: Likewise. * lto-wpa-fixup.c: Likewise. * matrix-reorg.c: Likewise. * mcf.c: Likewise. * mode-switching.c: Likewise. * modulo-sched.c: Likewise. * omega.c: Likewise. * omega.h: Likewise. * omp-low.c: Likewise. * optabs.c: Likewise. * optabs.h: Likewise. * opts-common.c: Likewise. * opts.c: Likewise. * params.def: Likewise. * params.h: Likewise. * passes.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * predict.def: Likewise. * pretty-print.c: Likewise. * pretty-print.h: Likewise. * print-rtl.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * read-rtl.c: Likewise. * real.c: Likewise. * recog.c: Likewise. * reg-stack.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regmove.c: Likewise. * regrename.c: Likewise. * regs.h: Likewise. * regstat.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * resource.c: Likewise. * rtl.c: Likewise. * rtl.def: Likewise. * rtl.h: Likewise. * rtlanal.c: Likewise. * sbitmap.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-int.h: Likewise. * sched-rgn.c: Likewise. * sched-vis.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-dump.h: Likewise. * sel-sched-ir.c: Likewise. * sel-sched-ir.h: Likewise. * sel-sched.c: Likewise. * sel-sched.h: Likewise. * sese.c: Likewise. * sese.h: Likewise. * simplify-rtx.c: Likewise. * stack-ptr-mod.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * stringpool.c: Likewise. * stub-objc.c: Likewise. * sync-builtins.def: Likewise. * target-def.h: Likewise. * target.h: Likewise. * targhooks.c: Likewise. * targhooks.h: Likewise. * timevar.c: Likewise. * tlink.c: Likewise. * toplev.c: Likewise. * toplev.h: Likewise. * tracer.c: Likewise. * tree-affine.c: Likewise. * tree-affine.h: Likewise. * tree-browser.def: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-chrec.h: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-data-ref.h: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-dump.h: Likewise. * tree-eh.c: Likewise. * tree-flow-inline.h: Likewise. * tree-flow.h: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-nomudflap.c: Likewise. * tree-nrv.c: Likewise. * tree-object-size.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-pass.h: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-copy.c: Likewise. * tree-ssa-copyrename.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-ifcombine.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-ch.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop-unswitch.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-operands.c: Likewise. * tree-ssa-operands.h: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sink.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-ter.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa.c: Likewise. * tree-ssanames.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-tailcall.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * tree.def: Likewise. * tree.h: Likewise. * treestruct.def: Likewise. * unwind-compat.c: Likewise. * unwind-dw2-fde-glibc.c: Likewise. * unwind-dw2.c: Likewise. * value-prof.c: Likewise. * value-prof.h: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vec.c: Likewise. * vec.h: Likewise. * vmsdbgout.c: Likewise. * web.c: Likewise. * xcoffout.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154645 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 34a8e9d8d07..2991c9e0b50 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -190,7 +190,7 @@ remap_ssa_name (tree name, copy_body_data *id) new_tree = remap_decl (SSA_NAME_VAR (name), id); /* We might've substituted constant or another SSA_NAME for - the variable. + the variable. Replace the SSA name representing RESULT_DECL by variable during inlining: this saves us from need to introduce PHI node in a case @@ -223,7 +223,7 @@ remap_ssa_name (tree name, copy_body_data *id) { gimple_stmt_iterator gsi = gsi_last_bb (id->entry_bb); gimple init_stmt; - + init_stmt = gimple_build_assign (new_tree, fold_convert (TREE_TYPE (new_tree), integer_zero_node)); @@ -277,7 +277,7 @@ remap_decl (tree decl, copy_body_data *id) { /* Make a copy of the variable or label. */ tree t = id->copy_decl (decl, id); - + /* Remember it, so that if we encounter this local entity again we can reuse this copy. Do this early because remap_type may need this decl for TYPE_STUB_DECL. */ @@ -493,7 +493,7 @@ remapped_type (tree type, copy_body_data *id) /* The type only needs remapping if it's variably modified. */ /* Decide if DECL can be put into BLOCK_NONLOCAL_VARs. */ - + static bool can_be_nonlocal (tree decl, copy_body_data *id) { @@ -561,7 +561,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) /* If we didn't remap this variable, we can't mess with its TREE_CHAIN. If we remapped this variable to the return slot, it's already declared somewhere else, so don't declare it here. */ - + if (new_var == id->retvar) ; else if (!new_var) @@ -1095,7 +1095,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) && id->remapping_type_depth == 0 && !processing_debug_stmt) add_referenced_var (*tp); - + /* If EXPR has block defined, map it to newly constructed block. When inlining we want EXPRs without block appear in the block of function call. */ @@ -1247,7 +1247,7 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) case GIMPLE_TRY: s1 = remap_gimple_seq (gimple_try_eval (stmt), id); s2 = remap_gimple_seq (gimple_try_cleanup (stmt), id); - copy = gimple_build_try (s1, s2, gimple_try_kind (stmt)); + copy = gimple_build_try (s1, s2, gimple_try_kind (stmt)); break; case GIMPLE_WITH_CLEANUP_EXPR: @@ -1448,7 +1448,7 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) if (skip_first) walk_tree (gimple_op_ptr (copy, 1), remap_gimple_op_r, &wi, NULL); else - walk_gimple_op (copy, remap_gimple_op_r, &wi); + walk_gimple_op (copy, remap_gimple_op_r, &wi); /* Clear the copied virtual operands. We are not remapping them here but are going to recreate them from scratch. */ @@ -1642,7 +1642,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* We could also just rescale the frequency, but doing so would introduce roundoff errors and make verifier unhappy. */ - edge->frequency + edge->frequency = compute_call_stmt_bb_frequency (id->dst_node->decl, copy_basic_block); if (dump_file @@ -1681,7 +1681,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* Constant propagation on argument done during inlining may create new direct call. Produce an edge for it. */ - if ((!edge + if ((!edge || (edge->indirect_call && id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)) && is_gimple_call (stmt) @@ -1700,7 +1700,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) cgraph_create_edge_including_clones (id->dst_node, dest, stmt, bb->count, - compute_call_stmt_bb_frequency (id->dst_node->decl, + compute_call_stmt_bb_frequency (id->dst_node->decl, copy_basic_block), bb->loop_depth, CIF_ORIGINALLY_INDIRECT_CALL); else @@ -1955,7 +1955,7 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id) new_arg = force_gimple_operand (new_arg, &stmts, true, NULL); gsi_insert_seq_on_edge_immediate (new_edge, stmts); } - add_phi_arg (new_phi, new_arg, new_edge, + add_phi_arg (new_phi, new_arg, new_edge, gimple_phi_arg_location_from_edge (phi, old_edge)); } } @@ -2569,7 +2569,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, STRIP_USELESS_TYPE_CONVERSION (return_slot_addr); /* We are going to construct *&return_slot and we can't do that - for variables believed to be not addressable. + for variables believed to be not addressable. FIXME: This check possibly can match, because values returned via return slot optimization are not believed to have address @@ -2687,7 +2687,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, use = var; if (!useless_type_conversion_p (caller_type, TREE_TYPE (var))) use = fold_convert (caller_type, var); - + STRIP_USELESS_TYPE_CONVERSION (use); if (DECL_BY_REFERENCE (result)) @@ -2747,7 +2747,7 @@ cannot_copy_type_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, UNION_TYPE nodes, then it goes into infinite recursion on a structure containing a pointer to its own type. If it doesn't, then the type node for S doesn't get adjusted properly when - F is inlined. + F is inlined. ??? This is likely no longer true, but it's too late in the 4.0 cycle to try to find out. This should be checked for 4.1. */ @@ -3270,7 +3270,7 @@ estimate_num_insns (gimple stmt, eni_weights *weights) case GIMPLE_SWITCH: /* Take into account cost of the switch + guess 2 conditional jumps for - each case label. + each case label. TODO: once the switch expansion logic is sufficiently separated, we can do better job on estimating cost of the switch. */ @@ -3293,7 +3293,7 @@ estimate_num_insns (gimple stmt, eni_weights *weights) cost = weights->target_builtin_call_cost; else cost = weights->call_cost; - + if (decl && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (decl)) { @@ -3746,9 +3746,9 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Inlining "); - print_generic_expr (dump_file, id->src_fn, 0); + print_generic_expr (dump_file, id->src_fn, 0); fprintf (dump_file, " to "); - print_generic_expr (dump_file, id->dst_fn, 0); + print_generic_expr (dump_file, id->dst_fn, 0); fprintf (dump_file, " with frequency %i\n", cg_edge->frequency); } @@ -4043,11 +4043,11 @@ optimize_inline_calls (tree fn) gcc_assert (e->inline_failed); } #endif - + /* Fold the statements before compacting/renumbering the basic blocks. */ fold_marked_statements (last, id.statements_to_fold); pointer_set_destroy (id.statements_to_fold); - + gcc_assert (!id.debug_stmts); /* Renumber the (code) basic_blocks consecutively. */ @@ -4515,14 +4515,14 @@ copy_decl_for_dup_finish (copy_body_data *id, tree decl, tree copy) DECL_IGNORED_P (copy) = DECL_IGNORED_P (decl); /* Set the DECL_ABSTRACT_ORIGIN so the debugging routines know what - declaration inspired this copy. */ + declaration inspired this copy. */ DECL_ABSTRACT_ORIGIN (copy) = DECL_ORIGIN (decl); /* The new variable/label has no RTL, yet. */ if (CODE_CONTAINS_STRUCT (TREE_CODE (copy), TS_DECL_WRTL) && !TREE_STATIC (copy) && !DECL_EXTERNAL (copy)) SET_DECL_RTL (copy, NULL_RTX); - + /* These args would always appear unused, if not for this. */ TREE_USED (copy) = 1; @@ -4733,7 +4733,7 @@ delete_unreachable_blocks_update_callgraph (copy_body_data *id) else cgraph_remove_edge (e); } - + if (node->clones) node = node->clones; else if (node->next_sibling_clone) @@ -4796,9 +4796,9 @@ update_clone_info (copy_body_data * id) /* Create a copy of a function's tree. OLD_DECL and NEW_DECL are FUNCTION_DECL tree nodes of the original function and the new copied function - respectively. In case we want to replace a DECL - tree with another tree while duplicating the function's - body, TREE_MAP represents the mapping between these + respectively. In case we want to replace a DECL + tree with another tree while duplicating the function's + body, TREE_MAP represents the mapping between these trees. If UPDATE_CLONES is set, the call_stmt fields of edges of clones of the function will be updated. */ void @@ -4862,7 +4862,7 @@ tree_function_versioning (tree old_decl, tree new_decl, old_transforms_to_apply, i)); } - + id.copy_decl = copy_decl_no_change; id.transform_call_graph_edges = update_clones ? CB_CGE_MOVE_CLONES : CB_CGE_MOVE; @@ -4876,14 +4876,14 @@ tree_function_versioning (tree old_decl, tree new_decl, initialize_cfun (new_decl, old_decl, old_entry_block->count); push_cfun (DECL_STRUCT_FUNCTION (new_decl)); - + /* Copy the function's static chain. */ p = DECL_STRUCT_FUNCTION (old_decl)->static_chain_decl; if (p) DECL_STRUCT_FUNCTION (new_decl)->static_chain_decl = copy_static_chain (DECL_STRUCT_FUNCTION (old_decl)->static_chain_decl, &id); - + /* If there's a tree_map, prepare for substitution. */ if (tree_map) for (i = 0; i < VEC_length (ipa_replace_map_p, tree_map); i++) @@ -4898,7 +4898,7 @@ tree_function_versioning (tree old_decl, tree new_decl, if (TREE_CODE (op) == VIEW_CONVERT_EXPR) op = TREE_OPERAND (op, 0); - + if (TREE_CODE (op) == ADDR_EXPR) { op = TREE_OPERAND (op, 0); @@ -4921,12 +4921,12 @@ tree_function_versioning (tree old_decl, tree new_decl, DECL_ARGUMENTS (new_decl) = copy_arguments_for_versioning (DECL_ARGUMENTS (old_decl), &id, args_to_skip, &vars); - + DECL_INITIAL (new_decl) = remap_blocks (DECL_INITIAL (id.src_fn), &id); - + /* Renumber the lexical scoping (non-code) blocks consecutively. */ number_blocks (id.dst_fn); - + declare_inline_vars (DECL_INITIAL (new_decl), vars); if (DECL_STRUCT_FUNCTION (old_decl)->local_decls != NULL_TREE) @@ -4942,18 +4942,18 @@ tree_function_versioning (tree old_decl, tree new_decl, tree_cons (NULL_TREE, remap_decl (var, &id), cfun->local_decls); } - + /* Copy the Function's body. */ copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR); - + if (DECL_RESULT (old_decl) != NULL_TREE) { tree *res_decl = &DECL_RESULT (old_decl); DECL_RESULT (new_decl) = remap_decl (*res_decl, &id); lang_hooks.dup_lang_specific_decl (DECL_RESULT (new_decl)); } - + /* Renumber the lexical scoping (non-code) blocks consecutively. */ number_blocks (new_decl); -- cgit v1.2.1 From f018d957a72d418d69c6d2d8bc80c9415666a9f6 Mon Sep 17 00:00:00 2001 From: jakub Date: Sat, 28 Nov 2009 16:21:00 +0000 Subject: * matrix-reorg.c (analyze_matrix_allocation_site): Remove unused malloc_fname variable. (check_allocation_function): Remove unused gsi and bb_level_0 variables. (transform_access_sites): Remove unused d_type_size and d_type_size_k variables. * omega.c (resurrect_subs): Remove unused n variable. (omega_solve_geq): Remove unused neweqns variable. * lto-streamer-in.c (lto_read_tree): Remove unused end_marker variable. * tree-inline.c (declare_return_variable): Remove USE_P argument, return use instead of var. (remap_decl, remap_block): Remove unused fn variable. (expand_call_inline): Remove unused retvar variable, adjust declare_return_variable caller. (optimize_inline_calls): Remove unused prev_fn variable. * tree-vect-slp.c (vect_analyze_slp_instance): Remove unused ncopies variable. (vect_create_mask_and_perm): Remove unused group_size and dr_chain_size variables. * tree-ssa-loop-niter.c (split_to_var_and_offset): Handle MINUS_EXPR properly. * tree-vect-loop.c (vect_analyze_loop_form): Remove unused backedge variable. (vect_create_epilog_for_reduction): Remove unused bytesize variable. * omp-low.c (workshare_safe_to_combine_p): Remove par_entry_bb parameter. Remove unused par_stmt variable. (determine_parallel_type): Adjust workshare_safe_to_combine_p caller. (expand_omp_sections): Remove unused l1 variable. (lower_omp_for): Remove unused ilist variable. * tree-loop-distribution.c (mark_nodes_having_upstream_mem_writes): Remove unused has_upstream_mem_write_p variable. * recog.c (decode_asm_operands): Remove unused noperands variable. * tree-ssa-alias.c (refs_may_alias_p_1): Remove unused size1 and size2 variable. * libgcov.c (__gcov_merge_delta): Remove unused last variable. * tree-call-cdce.c (gen_conditions_for_pow_int_base): Remove unused base_nm variable. (gen_conditions_for_pow): Remove unused ec variable. * tree-ssa-sccvn.c (vn_reference_lookup_3): Remove unused size variable. * ipa-struct-reorg.c (program_redefines_malloc_p): Remove unused fndecl variable. * tree-ssa-sink.c (statement_sink_location): Remove unused code variable. * regmove.c (copy_src_to_dest): Remove unused insn_uid and move_uid variables. * tree-complex.c (create_one_component_var): Remove unused inner_type variable. * calls.c (emit_call_1): Don't GEN_INT (struct_value_size) unnecessarily when GEN_*CALL omits that argument. * regrename.c (regrename_optimize): Remove unused regs_seen variable. (build_def_use): Remove unused icode variable. * ipa-pure-const.c (check_call): Remove unused callee and avail variables. * tree-dfa.c (add_referenced_var): Remove unused v_ann variable. * tree-vect-patterns.c (vect_recog_pow_pattern): Remove unused type variable. (vect_pattern_recog): Remove unused stmt variable. * sel-sched-ir.c (make_regions_from_the_rest): Remove unused new_regions variable. * postreload.c (reload_cse_simplify_operands): Remove unused mode variable. * tree-parloops.c (create_call_for_reduction_1): Remove unused addr_type variable. (create_parallel_loop): Remove unused res variable. (gen_parallel_loop): Remove unused nloop variable. * tree-vect-loop-manip.c (vect_loop_versioning): Likewise. * value-prof.c (gimple_mod_subtract_transform, gimple_stringops_transform): Remove unused value variable. (gimple_stringops_values_to_profile): Remove unused fcode variable. * tree-vrp.c (register_new_assert_for): Remove unused found variable. (vrp_visit_switch_stmt): Remove unused n variable. * tree-vect-stmts.c (vectorizable_conversion): Remove unused expr variable. (vectorizable_operation): Remove unused shift_p variable. (vectorizable_store): Remove unused first_stmt_vinfo variable. * tree-ssa-operands.c (add_stmt_operand): Remove unused v_ann variable. * tree-vect-data-refs.c (vect_analyze_data_refs): Remove unused bb variable. (vect_permute_store_chain): Remove unused scalar_dest variable. (vect_supportable_dr_alignment): Remove unused invariant_in_outerloop variable. * tree-ssa-threadupdate.c (thread_single_edge): Remove unused local_info variable. * tree-optimize.c (tree_rest_of_compilation): Remove unused node variable. * optabs.c (expand_binop): Remove unused equiv_value variable. (emit_libcall_block): Remove unused prev variable. (init_optabs): Remove unused int_mode variable. * tree-ssa-structalias.c (scc_visit): Remove unused have_ref_node variable. (do_structure_copy): Remove unused lhsbase and rhsbase variables. (find_func_aliases): Remove unused rhstype variable. (ipa_pta_execute): Remove unused varid variable. gcc/objc/ * objc-act.c (generate_shared_structures): Remove unused sc_spec and decl_specs variables. (objc_build_message_expr): Remove unused loc variable. (objc_finish_message_expr): Remove unused saved_rtype variable. (encode_field_decl): Remove unused type variable. gcc/lto/ * lto-lang.c (handle_nonnull_attribute): Remove unused attr_arg_num variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154726 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 2991c9e0b50..a70b5b1cbea 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -118,7 +118,7 @@ eni_weights eni_time_weights; /* Prototypes. */ -static tree declare_return_variable (copy_body_data *, tree, tree, tree *); +static tree declare_return_variable (copy_body_data *, tree, tree); static void remap_block (tree *, copy_body_data *); static void copy_bind_expr (tree *, int *, copy_body_data *); static tree mark_local_for_remap_r (tree *, int *, void *); @@ -256,10 +256,8 @@ tree remap_decl (tree decl, copy_body_data *id) { tree *n; - tree fn; /* We only remap local variables in the current function. */ - fn = id->src_fn; /* See if we have remapped this declaration. */ @@ -590,7 +588,6 @@ remap_block (tree *block, copy_body_data *id) { tree old_block; tree new_block; - tree fn; /* Make the new block. */ old_block = *block; @@ -607,8 +604,6 @@ remap_block (tree *block, copy_body_data *id) &BLOCK_NONLOCALIZED_VARS (new_block), id); - fn = id->dst_fn; - if (id->transform_lang_insert_block) id->transform_lang_insert_block (new_block); @@ -2533,13 +2528,11 @@ initialize_inlined_parameters (copy_body_data *id, gimple stmt, is set only for CALL_EXPR_RETURN_SLOT_OPT. MODIFY_DEST, if non-null, was the LHS of the MODIFY_EXPR to which this call is the RHS. - The return value is a (possibly null) value that is the result of the - function as seen by the callee. *USE_P is a (possibly null) value that - holds the result as seen by the caller. */ + The return value is a (possibly null) value that holds the result + as seen by the caller. */ static tree -declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, - tree *use_p) +declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) { tree callee = id->src_fn; tree caller = id->dst_fn; @@ -2551,10 +2544,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, /* We don't need to do anything for functions that don't return anything. */ if (!result || VOID_TYPE_P (callee_type)) - { - *use_p = NULL_TREE; - return NULL_TREE; - } + return NULL_TREE; /* If there was a return slot, then the return value is the dereferenced address of that object. */ @@ -2705,8 +2695,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, /* Remember this so we can ignore it in remap_decls. */ id->retvar = var; - *use_p = use; - return var; + return use; } /* Callback through walk_tree. Determine if a DECL_INITIAL makes reference @@ -3506,7 +3495,7 @@ get_indirect_callee_fndecl (struct cgraph_node *node, gimple stmt) static bool expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) { - tree retvar, use_retvar; + tree use_retvar; tree fn; struct pointer_map_t *st, *dst; tree return_slot; @@ -3725,7 +3714,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) } /* Declare the return variable for the function. */ - retvar = declare_return_variable (id, return_slot, modify_dest, &use_retvar); + use_retvar = declare_return_variable (id, return_slot, modify_dest); /* Add local vars in this inlined callee to caller. */ t_step = id->src_cfun->local_decls; @@ -3981,7 +3970,6 @@ unsigned int optimize_inline_calls (tree fn) { copy_body_data id; - tree prev_fn; basic_block bb; int last = n_basic_blocks; struct gimplify_ctx gctx; @@ -3998,12 +3986,8 @@ optimize_inline_calls (tree fn) id.src_node = id.dst_node = cgraph_node (fn); id.dst_fn = fn; /* Or any functions that aren't finished yet. */ - prev_fn = NULL_TREE; if (current_function_decl) - { - id.dst_fn = current_function_decl; - prev_fn = current_function_decl; - } + id.dst_fn = current_function_decl; id.copy_decl = copy_decl_maybe_to_var; id.transform_call_graph_edges = CB_CGE_DUPLICATE; -- cgit v1.2.1 From 284545178e8dd05756e5b236cf3b47834b87abf2 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sun, 29 Nov 2009 10:32:08 +0000 Subject: * cgraph.c (same_body_alias_1): Break out of (same_body_alias): ... here; remove comdat check; it is handled in cp already. (cgraph_add_thunk): New. (dump_cgraph_node): Dump aliases and thunks. * cgraph.h (cgraph_thunk_info): New structure. (struct cgraph_node): Add thunk info. (cgraph_add_thunk): New. * cgraphunit.c (cgraph_emit_thunks): Remove. (cgraph_finalize_compilation_unit): Do not call cgraph_emit_thunks. (assemble_thunk): New function. (cgraph_expand_function): Handle thunks. (thunk_adjust): New. (init_lowered_empty_function): New. * optimize.c (maybe_clone_body): Emit thunks associated to alias. * Make-lang.in (method.o): Add dependency on gimple.h. * method.c: Include gimple.h (make_alias_for_thunk): Use same body alias instead of assemble_alias. (use_thunk): Drop codegen; use cgraph_add_thunk; gimplify generic thunks. * semantics.c (expand_or_defer_fn): Emit associated thunks. * cp-objcp-common.h (LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Remove. * lto-cgraph.c (lto_output_node): Stream thunk info. (input_node): Likewise. * langhooks.h (lang_hooks_for_callgraph): Remove emit_associated_thunks. * langhooks-def.h (LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Remove. (LANG_HOOKS_CALLGRAPH_INITIALIZER): Update. * i386.c (x86_output_mi_thunk): Make output prettier. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154736 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a70b5b1cbea..10baf62b0c0 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3832,10 +3832,6 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) (*debug_hooks->outlining_inline_function) (cg_edge->callee->decl); /* Update callgraph if needed. */ - if (cg_edge->callee->clone_of - && !cg_edge->callee->clone_of->next_sibling_clone - && !cg_edge->callee->analyzed) - cgraph_remove_node (cg_edge->callee); cgraph_remove_node (cg_edge->callee); id->block = NULL_TREE; -- cgit v1.2.1 From edbb328f08335dc95672cc24f135acd556c195cd Mon Sep 17 00:00:00 2001 From: rguenth Date: Tue, 1 Dec 2009 14:22:50 +0000 Subject: 2009-12-01 Richard Guenther * tree-inline.c (copy_tree_body_r): Do not set TREE_BLOCK to the block of the call when remapping a type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154873 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 10baf62b0c0..3c909419bd2 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1093,10 +1093,10 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) /* If EXPR has block defined, map it to newly constructed block. When inlining we want EXPRs without block appear in the block - of function call. */ + of function call if we are not remapping a type. */ if (EXPR_P (*tp)) { - new_block = id->block; + new_block = id->remapping_type_depth == 0 ? id->block : NULL; if (TREE_BLOCK (*tp)) { tree *n; -- cgit v1.2.1 From ee3f5fc0f04108d47a518ce7efadd87eb51a9cc3 Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 10 Dec 2009 20:50:47 +0000 Subject: PR middle-end/42228 PR middle-end/42110 * cgraph.c (cgraph_create_edge_including_clones): Add old_stmt parameter; update edge if it already exists. (cgraph_remove_node): Handle correctly cases where we are removing node having clones. * cgraph.h (cgraph_create_edge_including_clones): Declare. (verify_cgraph_node): Add missing error_found = true code. (cgraph_materialize_all_clones): Remove call edges of dead nodes. * ipa.c (cgraph_remove_unreachable_nodes): Correctly look for master clone; fix double linked list removal. * tree-inline.c (copy_bb): Update cgraph_create_edge_including_clones call; fix frequency of newly created edge. * g++.dg/torture/pr42110.C: new file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155140 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3c909419bd2..aacd903bac5 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1694,13 +1694,15 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, || !id->src_node->analyzed); if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) cgraph_create_edge_including_clones - (id->dst_node, dest, stmt, bb->count, + (id->dst_node, dest, orig_stmt, stmt, bb->count, compute_call_stmt_bb_frequency (id->dst_node->decl, copy_basic_block), bb->loop_depth, CIF_ORIGINALLY_INDIRECT_CALL); else cgraph_create_edge (id->dst_node, dest, stmt, - bb->count, CGRAPH_FREQ_BASE, + bb->count, + compute_call_stmt_bb_frequency + (id->dst_node->decl, copy_basic_block), bb->loop_depth)->inline_failed = CIF_ORIGINALLY_INDIRECT_CALL; if (dump_file) -- cgit v1.2.1 From 9f28a7ee8ff2cd44964cffaa0e12a87664cf2dba Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 12 Jan 2010 09:43:31 +0000 Subject: PR tree-optimization/42645 * tree-inline.c (processing_debug_stmt): Move earlier. Make static. (remap_ssa_name): If processing_debug_stmt and name wasn't found in decl_map, set processing_debug_stmt to -1 and return name without any remapping. * g++.dg/other/pr42645-1.C: New test. * g++.dg/other/pr42645-2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155830 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index aacd903bac5..883a431c7ff 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1,5 +1,5 @@ /* Tree inlining. - Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by Alexandre Oliva @@ -171,6 +171,12 @@ insert_debug_decl_map (copy_body_data *id, tree key, tree value) *pointer_map_insert (id->debug_map, key) = value; } +/* If nonzero, we're remapping the contents of inlined debug + statements. If negative, an error has occurred, such as a + reference to a variable that isn't available in the inlined + context. */ +static int processing_debug_stmt = 0; + /* Construct new SSA name for old NAME. ID is the inline context. */ static tree @@ -185,6 +191,12 @@ remap_ssa_name (tree name, copy_body_data *id) if (n) return unshare_expr (*n); + if (processing_debug_stmt) + { + processing_debug_stmt = -1; + return name; + } + /* Do not set DEF_STMT yet as statement is not copied yet. We do that in copy_bb. */ new_tree = remap_decl (SSA_NAME_VAR (name), id); @@ -244,12 +256,6 @@ remap_ssa_name (tree name, copy_body_data *id) return new_tree; } -/* If nonzero, we're remapping the contents of inlined debug - statements. If negative, an error has occurred, such as a - reference to a variable that isn't available in the inlined - context. */ -int processing_debug_stmt = 0; - /* Remap DECL during the copying of the BLOCK tree for the function. */ tree -- cgit v1.2.1 From e066716049672ad18c664157f2762b3e06dbd32a Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 14 Jan 2010 22:38:29 +0000 Subject: PR debug/42657 * tree-inline.c (copy_debug_stmt): Don't reset debug stmt just because its first operand is a non-localized variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155917 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 883a431c7ff..d7e515a4d1b 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2160,6 +2160,12 @@ copy_debug_stmt (gimple stmt, copy_body_data *id) gcc_assert (TREE_CODE (*n) == VAR_DECL); t = *n; } + else if (TREE_CODE (t) == VAR_DECL + && !TREE_STATIC (t) + && gimple_in_ssa_p (cfun) + && !pointer_map_contains (id->decl_map, t) + && !var_ann (t)) + /* T is a non-localized variable. */; else walk_tree (&t, remap_gimple_op_r, &wi, NULL); -- cgit v1.2.1 From e6a18807bb867001dd062d893c1c3f23c8ce2bbd Mon Sep 17 00:00:00 2001 From: rguenth Date: Wed, 20 Jan 2010 11:47:39 +0000 Subject: 2010-01-20 Richard Guenther * tree-inline.c (estimate_num_insns): Handle EH builtins. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156073 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index d7e515a4d1b..e08842ca829 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3310,6 +3310,12 @@ estimate_num_insns (gimple stmt, eni_weights *weights) cost = weights->target_builtin_call_cost; break; + /* Exception state returns or moves registers around. */ + case BUILT_IN_EH_FILTER: + case BUILT_IN_EH_POINTER: + case BUILT_IN_EH_COPY_VALUES: + return 0; + default: break; } -- cgit v1.2.1 From efcca74af93b05fe0ab84263de63c8e66b6a86e3 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 27 Jan 2010 15:09:23 +0000 Subject: PR middle-end/42874 * tree-inline.c (cannot_copy_type_1): Removed. (copy_forbidden): Don't forbid copying of functions containing records/unions with variable length fields. * gcc.dg/vla-22.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156287 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e08842ca829..815d88af066 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2730,39 +2730,6 @@ has_label_address_in_static_1 (tree *nodep, int *walk_subtrees, void *fnp) return NULL_TREE; } -/* Callback through walk_tree. Determine if we've got an aggregate - type that we can't support; return non-null if so. */ - -static tree -cannot_copy_type_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, - void *data ATTRIBUTE_UNUSED) -{ - tree t, node = *nodep; - - if (TREE_CODE (node) == RECORD_TYPE || TREE_CODE (node) == UNION_TYPE) - { - /* We cannot inline a function of the form - - void F (int i) { struct S { int ar[i]; } s; } - - Attempting to do so produces a catch-22. - If walk_tree examines the TYPE_FIELDS chain of RECORD_TYPE/ - UNION_TYPE nodes, then it goes into infinite recursion on a - structure containing a pointer to its own type. If it doesn't, - then the type node for S doesn't get adjusted properly when - F is inlined. - - ??? This is likely no longer true, but it's too late in the 4.0 - cycle to try to find out. This should be checked for 4.1. */ - for (t = TYPE_FIELDS (node); t; t = TREE_CHAIN (t)) - if (variably_modified_type_p (TREE_TYPE (t), NULL)) - return node; - } - - return NULL_TREE; -} - - /* Determine if the function can be copied. If so return NULL. If not return a string describng the reason for failure. */ @@ -2805,16 +2772,6 @@ copy_forbidden (struct function *fun, tree fndecl) "address of local label in a static variable"); goto fail; } - - if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl) - && variably_modified_type_p (TREE_TYPE (decl), NULL) - && walk_tree_without_duplicates (&TREE_TYPE (decl), - cannot_copy_type_1, NULL)) - { - reason = G_("function %q+F can never be copied " - "because it uses variable sized variables"); - goto fail; - } } fail: -- cgit v1.2.1 From 7547883d18dd46ad4718913b72d449076ab76c27 Mon Sep 17 00:00:00 2001 From: rguenth Date: Wed, 27 Jan 2010 16:00:31 +0000 Subject: 2010-01-27 Richard Guenther PR middle-end/42878 * tree-inline.c (remap_decl): Delay remapping of SSA name default definitions until we need them. * gcc.dg/torture/pr42878-1.c: New testcase. * gcc.dg/torture/pr42878-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156291 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 815d88af066..9c560b1056c 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -311,17 +311,7 @@ remap_decl (tree decl, copy_body_data *id) && (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == RESULT_DECL || TREE_CODE (t) == PARM_DECL)) { - tree def = gimple_default_def (id->src_cfun, decl); get_var_ann (t); - if (TREE_CODE (decl) != PARM_DECL && def) - { - tree map = remap_ssa_name (def, id); - /* Watch out RESULT_DECLs whose SSA names map directly - to them. */ - if (TREE_CODE (map) == SSA_NAME - && gimple_nop_p (SSA_NAME_DEF_STMT (map))) - set_default_def (t, map); - } add_referenced_var (t); } return t; -- cgit v1.2.1 From c21cf15cd9421a802ab70cd461d4e135e20db943 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 22 Feb 2010 15:53:27 +0000 Subject: 2010-02-22 Richard Guenther PR lto/43045 * tree-inline.c (declare_return_variable): Use the type of the call stmt lhs if available. * gfortran.dg/lto/20100222-1_0.f03: New testcase. * gfortran.dg/lto/20100222-1_1.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156966 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 9c560b1056c..de8ca707ce2 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2542,9 +2542,16 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) tree caller = id->dst_fn; tree result = DECL_RESULT (callee); tree callee_type = TREE_TYPE (result); - tree caller_type = TREE_TYPE (TREE_TYPE (callee)); + tree caller_type; tree var, use; + /* Handle type-mismatches in the function declaration return type + vs. the call expression. */ + if (modify_dest) + caller_type = TREE_TYPE (modify_dest); + else + caller_type = TREE_TYPE (TREE_TYPE (callee)); + /* We don't need to do anything for functions that don't return anything. */ if (!result || VOID_TYPE_P (callee_type)) -- cgit v1.2.1 From f24c0e3a57a4720d43000eacaa57c61fd49d79c4 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 12 Mar 2010 13:04:37 +0000 Subject: PR debug/43329 * tree-inline.c (remap_decls): Put old_var rather than origin_var into *nonlocalized_list vector. * dwarf2out.c (gen_formal_parameter_die): Call decl_ultimate_origin even if origin is non-NULL. (gen_variable_die): Likewise. (process_scope_var): Don't change origin. (gen_decl_die): Likewise. * tree-cfgcleanup.c (remove_forwarder_block): Check single_pred_p before adding new edges instead of after it, fix moving over debug stmts. * gcc.dg/guality/pr43329-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157402 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index de8ca707ce2..f3c420475df 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -533,7 +533,6 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) for (old_var = decls; old_var; old_var = TREE_CHAIN (old_var)) { tree new_var; - tree origin_var = DECL_ORIGIN (old_var); if (can_be_nonlocal (old_var, id)) { @@ -545,7 +544,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) && !DECL_IGNORED_P (old_var) && nonlocalized_list) - VEC_safe_push (tree, gc, *nonlocalized_list, origin_var); + VEC_safe_push (tree, gc, *nonlocalized_list, old_var); continue; } @@ -563,7 +562,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) && !DECL_IGNORED_P (old_var) && nonlocalized_list) - VEC_safe_push (tree, gc, *nonlocalized_list, origin_var); + VEC_safe_push (tree, gc, *nonlocalized_list, old_var); } else { -- cgit v1.2.1 From c596d83002a937c3943de34c6f47da047337f865 Mon Sep 17 00:00:00 2001 From: jamborm Date: Thu, 18 Mar 2010 20:07:13 +0000 Subject: 2010-03-18 Martin Jambor PR middle-end/42450 * cgraph.h (cgraph_redirect_edge_call_stmt_to_callee): Declare. * cgraphunit.c (cgraph_materialize_all_clones): Update calls in all non-clones. Moved call redirection... (cgraph_redirect_edge_call_stmt_to_callee): ...to this new function. (cgraph_materialize_all_clones): Dispose of all combined_args_to_skip bitmaps. (verify_cgraph_node): Do not check for edges pointing to wrong nodes in inline clones. * tree-inline.c (copy_bb): Call cgraph_redirect_edge_call_stmt_to_callee. * ipa.c (cgraph_remove_unreachable_nodes): Call cgraph_node_remove_callees even when there are used clones. * testsuite/g++.dg/torture/pr42450.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157546 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f3c420475df..e0928b9fe03 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1650,6 +1650,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, bb->frequency, copy_basic_block->frequency); } + stmt = cgraph_redirect_edge_call_stmt_to_callee (edge); } break; -- cgit v1.2.1 From cb24521686308314fadcd96cdfd23858aa19aa95 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 12 Apr 2010 15:20:48 +0000 Subject: 2010-04-12 Richard Guenther * gsstruct.def (GSS_CALL): New. * gimple.def (GIMPLE_CALL): Change to GSS_CALL. * gimple.h: Include tree-ssa-alias.h. (struct gimple_statement_call): New. (union gimple_statement_struct_d): Add gimple_call member. (gimple_call_reset_alias_info): Declare. (gimple_call_use_set): New function. (gimple_call_clobber_set): Likewise. * Makefile.in (GIMPLE_H): Add tree-ssa-alias.h. * gimple.c (gimple_call_reset_alias_info): New function. (gimple_build_call_1): Call it. * lto-streamer-in.c (input_gimple_stmt): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. (expand_call_inline): Remove callused handling. * cfgexpand.c (update_alias_info_with_stack_vars): Likewise. * tree-dfa.c (dump_variable): Likewise. * tree-parloops.c (parallelize_loops): Likewise. * tree-ssa.c (init_tree_ssa): Likewise. (delete_tree_ssa): Likewise. * tree-flow-inline.h (is_call_used): Remove. * tree-flow.h (struct gimple_df): Remove callused member. * tree-nrv.c (dest_safe_for_nrv_p): Adjust predicate. * tree-ssa-alias.c (dump_alias_info): Remove callused handling. (ref_maybe_used_by_call_p_1): Simplify. (call_may_clobber_ref_p_1): Likewise. * tree-ssa-structalias.c (compute_points_to_sets): Set the call stmt used and clobbered sets. * tree-tailcall.c (suitable_for_tail_opt_p): Adjust predicate. (find_tail_calls): Verify the tail call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158226 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e0928b9fe03..922ce52dd9d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1391,6 +1391,13 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) default: break; } + + /* Reset alias info. + ??? By maintaining DECL_PT_UID this should not + be necessary, but the plan is to only maintain + it when IPA-PTA was run. It's not too easy to + detect this here ... */ + gimple_call_reset_alias_info (copy); } break; @@ -3724,12 +3731,9 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) cg_edge->frequency * REG_BR_PROB_BASE / CGRAPH_FREQ_BASE, bb, return_block); - /* Reset the escaped and callused solutions. */ + /* Reset the escaped solution. */ if (cfun->gimple_df) - { - pt_solution_reset (&cfun->gimple_df->escaped); - pt_solution_reset (&cfun->gimple_df->callused); - } + pt_solution_reset (&cfun->gimple_df->escaped); /* Clean up. */ if (id->debug_map) -- cgit v1.2.1 From 1a981e1a975098bd537556d2b36f275f3bc075c7 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 15 Apr 2010 13:16:44 +0000 Subject: 2010-04-15 Richard Guenther * tree-ssa-structalias.c (struct variable_info): Add is_fn_info flag. (new_var_info): Initialize it. (dump_constraints): Support printing last added constraints. (debug_constraints): Adjust. (dump_constraint_graph): Likewise. (make_heapvar_for): Check for NULL cfun. (get_function_part_constraint): New function. (get_fi_for_callee): Likewise. (find_func_aliases): Properly implement IPA PTA constraints. (process_ipa_clobber): New function. (find_func_clobbers): Likewise. (insert_into_field_list_sorted): Remove. (create_function_info_for): Properly allocate vars for IPA mode. Do not use insert_into_field_list_sorted. (create_variable_info_for): Properly generate constraints for global vars in IPA mode. (dump_solution_for_var): Always dump the solution. (set_uids_in_ptset): Initialize DECL_PT_UID if in ipa-mode. (find_what_var_points_to): Adjust. (pt_solution_set): Change. (pt_solution_ior_into): New function. (pt_solution_empty_p): Export. (pt_solution_includes_global): Adjust. (pt_solution_includes_1): Likewise. (pt_solutions_intersect_1): Likewise. (dump_sa_points_to_info): Check some invariants. (solve_constraints): Move constraint dumping ... (compute_points_to_sets): ... here. (ipa_pta_execute): ... and here. (compute_may_aliases): Do not re-compute points-to info locally if IPA info is available. (ipa_escaped_pt): New global var. (ipa_pta_execute): Properly implement IPA PTA. * tree-into-ssa.c (dump_decl_set): Support dumping decls not in referenced-vars. * tree-flow.h (struct gimple_df): Add ipa_pta flag. * tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Adjust. (dump_points_to_solution): Likewise. * tree-dfa.c (dump_variable): Also dump DECL_PT_UID. * tree-inline.c (remap_ssa_name): Copy IPA points-to solution. (remap_gimple_stmt): Reset call clobber/use information if necessary. (copy_decl_to_var): Copy DECL_PT_UID. (copy_result_decl_to_var): Likewise. * tree.c (make_node_stat): Initialize DECL_PT_UID. (copy_node_stat): Copy it. * tree.h (DECL_PT_UID): New macro. (SET_DECL_PT_UID): Likewise. (DECL_PT_UID_SET_P): Likewise. (struct tree_decl_minimal): Add pt_uid member. * tree-ssa-alias.h (struct pt_solution): Add ipa_escaped flag. (pt_solution_empty_p): Declare. (pt_solution_set): Adjust. (ipa_escaped_pt): Declare. * cfgexpand.c (update_alias_info_with_stack_vars): Adjust. * gimple-pretty-print.c (pp_points_to_solution): New function. (dump_gimple_call): Dump call clobber/use information. * tree-dump.c (dump_option_value_in): Add TDF_ALIAS entry. * tree-pass.h (TDF_ALIAS): New dump option. * tree-pretty-print.c (dump_decl_name): Dump DECL_PT_UID if asked to. * doc/invoke.texi (-fipa-pta): Update documentation. * gcc.dg/ipa/ipa-pta-1.c: New testcase. * gcc.dg/ipa/ipa-pta-2.c: Likewise. * gcc.dg/ipa/ipa-pta-3.c: Likewise. * gcc.dg/ipa/ipa-pta-4.c: Likewise. * gcc.dg/ipa/ipa-pta-5.c: Likewise. * gcc.dg/ipa/ipa-pta-6.c: Likewise. * gcc.dg/ipa/ipa-pta-7.c: Likewise. * gcc.dg/ipa/ipa-pta-8.c: Likewise. * gcc.dg/ipa/ipa-pta-9.c: Likewise. * gcc.dg/ipa/ipa-pta-10.c: Likewise. * gcc.dg/ipa/ipa-pta-11.c: Likewise. * gcc.dg/ipa/ipa-pta-12.c: Likewise. * gcc.dg/ipa/ipa-pta-13.c: Likewise. * gcc.dg/torture/ipa-pta-2.c: Likewise. * gcc.dg/torture/ipa-pta-1.c: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158374 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 922ce52dd9d..b564fa58a74 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -211,11 +211,21 @@ remap_ssa_name (tree name, copy_body_data *id) && (TREE_CODE (SSA_NAME_VAR (name)) != RESULT_DECL || !id->transform_return_to_modify)) { + struct ptr_info_def *pi; new_tree = make_ssa_name (new_tree, NULL); insert_decl_map (id, name, new_tree); SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree) = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name); TREE_TYPE (new_tree) = TREE_TYPE (SSA_NAME_VAR (new_tree)); + /* At least IPA points-to info can be directly transferred. */ + if (id->src_cfun->gimple_df + && id->src_cfun->gimple_df->ipa_pta + && (pi = SSA_NAME_PTR_INFO (name)) + && !pi->pt.anything) + { + struct ptr_info_def *new_pi = get_ptr_info (new_tree); + new_pi->pt = pi->pt; + } if (gimple_nop_p (SSA_NAME_DEF_STMT (name))) { /* By inlining function having uninitialized variable, we might @@ -1392,12 +1402,11 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) break; } - /* Reset alias info. - ??? By maintaining DECL_PT_UID this should not - be necessary, but the plan is to only maintain - it when IPA-PTA was run. It's not too easy to - detect this here ... */ - gimple_call_reset_alias_info (copy); + /* Reset alias info if we didn't apply measures to + keep it valid over inlining by setting DECL_PT_UID. */ + if (!id->src_cfun->gimple_df + || !id->src_cfun->gimple_df->ipa_pta) + gimple_call_reset_alias_info (copy); } break; @@ -4516,6 +4525,8 @@ copy_decl_to_var (tree decl, copy_body_data *id) copy = build_decl (DECL_SOURCE_LOCATION (id->dst_fn), VAR_DECL, DECL_NAME (decl), type); + if (DECL_PT_UID_SET_P (decl)) + SET_DECL_PT_UID (copy, DECL_PT_UID (decl)); TREE_ADDRESSABLE (copy) = TREE_ADDRESSABLE (decl); TREE_READONLY (copy) = TREE_READONLY (decl); TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl); @@ -4541,6 +4552,8 @@ copy_result_decl_to_var (tree decl, copy_body_data *id) copy = build_decl (DECL_SOURCE_LOCATION (id->dst_fn), VAR_DECL, DECL_NAME (decl), type); + if (DECL_PT_UID_SET_P (decl)) + SET_DECL_PT_UID (copy, DECL_PT_UID (decl)); TREE_READONLY (copy) = TREE_READONLY (decl); TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl); if (!DECL_BY_REFERENCE (decl)) -- cgit v1.2.1 From 2bf96dd78f10196a20c8ae90c3f1eef8c859cc91 Mon Sep 17 00:00:00 2001 From: lauras Date: Fri, 23 Apr 2010 06:02:06 +0000 Subject: 2010-04-22 Laurynas Biveinis * sese.h (create_if_region_on_edge): Remove. * sese.c (create_if_region_on_edge): Make static. * tree-inline.c: Do not include ggc.h. * expr.c: Do not include ggc.h. * Makefile.in (tree-inline.o, expr.o): Remove $(GGC_H) from dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158661 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b564fa58a74..1d3008b2363 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -41,7 +41,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-mudflap.h" #include "tree-flow.h" #include "function.h" -#include "ggc.h" #include "tree-flow.h" #include "diagnostic.h" #include "except.h" -- cgit v1.2.1 From 33d8f01921475f1c755c4d98b00e054c5765494d Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 23 Apr 2010 15:18:24 +0000 Subject: 2010-04-23 Richard Guenther PR lto/43455 * tree-inline.c (tree_can_inline_p): Also check compatibility of return types. * gcc.dg/lto/20100423-1_0.c: New testcase. * gcc.dg/lto/20100423-1_1.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158669 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 1d3008b2363..59661a7d509 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -5082,7 +5082,7 @@ tree_can_inline_p (struct cgraph_edge *e) return false; } #endif - tree caller, callee; + tree caller, callee, lhs; caller = e->caller->decl; callee = e->callee->decl; @@ -5108,8 +5108,16 @@ tree_can_inline_p (struct cgraph_edge *e) return false; } + /* Do not inline calls where we cannot triviall work around mismatches + in argument or return types. */ if (e->call_stmt - && !gimple_check_call_args (e->call_stmt)) + && ((DECL_RESULT (callee) + && !DECL_BY_REFERENCE (DECL_RESULT (callee)) + && (lhs = gimple_call_lhs (e->call_stmt)) != NULL_TREE + && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)), + TREE_TYPE (lhs)) + && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs)) + || !gimple_check_call_args (e->call_stmt))) { e->inline_failed = CIF_MISMATCHED_ARGUMENTS; gimple_call_set_cannot_inline (e->call_stmt, true); -- cgit v1.2.1 From 125b6d78d39ec6f18cab9f54a07d474e496920c8 Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 26 Apr 2010 13:33:24 +0000 Subject: * cgraph.c (cgraph_create_node): Set node frequency to normal. (cgraph_clone_node): Copy function frequency. * cgraph.h (node_frequency): New enum (struct cgraph_node): Add. * final.c (rest_of_clean_state): Update. * lto-cgraph.c (lto_output_node): Output node frequency. (input_overwrite_node): Input node frequency. * tre-ssa-loop-ivopts (computation_cost): Update. * lto-streamer-out.c (output_function): Do not output function frequency. * predict.c (maybe_hot_frequency_p): Update and handle functions executed once. (cgraph_maybe_hot_edge_p): Likewise; use cgraph frequency instead of attribute lookup. (probably_never_executed_bb_p, optimize_function_for_size_p): Update. (compute_function_frequency): Set noreturn functions to be executed once. (choose_function_section): Update. * lto-streamer-in.c (input_function): Do not input function frequency. * function.c (allocate_struct_function): Do not initialize function frequency. * function.h (function_frequency): Remove. (struct function): Remove function frequency. * ipa-profile.c (CGRAPH_NODE_FREQUENCY): Remove. (try_update): Update. * tree-inline.c (initialize_cfun): Do not update function frequency. * passes.c (pass_init_dump_file): Update. * i386.c (ix86_compute_frame_layout): Update. (ix86_pad_returns): Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158732 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 59661a7d509..0c1293e6517 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2014,7 +2014,6 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count) cfun->last_verified = src_cfun->last_verified; cfun->va_list_gpr_size = src_cfun->va_list_gpr_size; cfun->va_list_fpr_size = src_cfun->va_list_fpr_size; - cfun->function_frequency = src_cfun->function_frequency; cfun->has_nonlocal_label = src_cfun->has_nonlocal_label; cfun->stdarg = src_cfun->stdarg; cfun->dont_save_pending_sizes_p = src_cfun->dont_save_pending_sizes_p; -- cgit v1.2.1 From 4ad4123ff27f8bf744879f33979bb97e349616dc Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 27 Apr 2010 05:41:33 +0000 Subject: * tree-inline.c (eni_inlining_weights): Remove. (estimate_num_insns): Special case more builtins. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158766 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 12 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 0c1293e6517..9fb9faf0d84 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -101,10 +101,6 @@ along with GCC; see the file COPYING3. If not see calls? */ -/* Weights that estimate_num_insns uses for heuristics in inlining. */ - -eni_weights eni_inlining_weights; - /* Weights that estimate_num_insns uses to estimate the size of the produced code. */ @@ -3268,22 +3264,93 @@ estimate_num_insns (gimple stmt, eni_weights *weights) if (decl && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (decl)) { + /* Builtins that expand to constants. */ case BUILT_IN_CONSTANT_P: - return 0; case BUILT_IN_EXPECT: - return 0; - - /* Prefetch instruction is not expensive. */ - case BUILT_IN_PREFETCH: - cost = weights->target_builtin_call_cost; - break; - + case BUILT_IN_OBJECT_SIZE: + case BUILT_IN_UNREACHABLE: + /* Simple register moves or loads from stack. */ + case BUILT_IN_RETURN_ADDRESS: + case BUILT_IN_EXTRACT_RETURN_ADDR: + case BUILT_IN_FROB_RETURN_ADDR: + case BUILT_IN_RETURN: + case BUILT_IN_AGGREGATE_INCOMING_ADDRESS: + case BUILT_IN_FRAME_ADDRESS: + case BUILT_IN_VA_END: + case BUILT_IN_STACK_SAVE: + case BUILT_IN_STACK_RESTORE: /* Exception state returns or moves registers around. */ case BUILT_IN_EH_FILTER: case BUILT_IN_EH_POINTER: case BUILT_IN_EH_COPY_VALUES: return 0; + /* builtins that are not expensive (that is they are most probably + expanded inline into resonably simple code). */ + case BUILT_IN_ABS: + case BUILT_IN_ALLOCA: + case BUILT_IN_BSWAP32: + case BUILT_IN_BSWAP64: + case BUILT_IN_CLZ: + case BUILT_IN_CLZIMAX: + case BUILT_IN_CLZL: + case BUILT_IN_CLZLL: + case BUILT_IN_CTZ: + case BUILT_IN_CTZIMAX: + case BUILT_IN_CTZL: + case BUILT_IN_CTZLL: + case BUILT_IN_FFS: + case BUILT_IN_FFSIMAX: + case BUILT_IN_FFSL: + case BUILT_IN_FFSLL: + case BUILT_IN_IMAXABS: + case BUILT_IN_FINITE: + case BUILT_IN_FINITEF: + case BUILT_IN_FINITEL: + case BUILT_IN_FINITED32: + case BUILT_IN_FINITED64: + case BUILT_IN_FINITED128: + case BUILT_IN_FPCLASSIFY: + case BUILT_IN_ISFINITE: + case BUILT_IN_ISINF_SIGN: + case BUILT_IN_ISINF: + case BUILT_IN_ISINFF: + case BUILT_IN_ISINFL: + case BUILT_IN_ISINFD32: + case BUILT_IN_ISINFD64: + case BUILT_IN_ISINFD128: + case BUILT_IN_ISNAN: + case BUILT_IN_ISNANF: + case BUILT_IN_ISNANL: + case BUILT_IN_ISNAND32: + case BUILT_IN_ISNAND64: + case BUILT_IN_ISNAND128: + case BUILT_IN_ISNORMAL: + case BUILT_IN_ISGREATER: + case BUILT_IN_ISGREATEREQUAL: + case BUILT_IN_ISLESS: + case BUILT_IN_ISLESSEQUAL: + case BUILT_IN_ISLESSGREATER: + case BUILT_IN_ISUNORDERED: + case BUILT_IN_VA_ARG_PACK: + case BUILT_IN_VA_ARG_PACK_LEN: + case BUILT_IN_VA_COPY: + case BUILT_IN_TRAP: + case BUILT_IN_SAVEREGS: + case BUILT_IN_POPCOUNTL: + case BUILT_IN_POPCOUNTLL: + case BUILT_IN_POPCOUNTIMAX: + case BUILT_IN_POPCOUNT: + case BUILT_IN_PARITYL: + case BUILT_IN_PARITYLL: + case BUILT_IN_PARITYIMAX: + case BUILT_IN_PARITY: + case BUILT_IN_LABS: + case BUILT_IN_LLABS: + case BUILT_IN_PREFETCH: + cost = weights->target_builtin_call_cost; + break; + default: break; } -- cgit v1.2.1 From d87cde43f6a51aa4406b3dcd792d604158c4f908 Mon Sep 17 00:00:00 2001 From: rguenth Date: Wed, 28 Apr 2010 10:28:24 +0000 Subject: 2010-04-28 Richard Guenther PR c++/43880 * tree-inline.c (copy_bind_expr): Also copy bind expr vars value-exprs. * g++.dg/torture/pr43880.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158824 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 9fb9faf0d84..7f35c4d60ca 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -665,9 +665,23 @@ copy_bind_expr (tree *tp, int *walk_subtrees, copy_body_data *id) } if (BIND_EXPR_VARS (*tp)) - /* This will remap a lot of the same decls again, but this should be - harmless. */ - BIND_EXPR_VARS (*tp) = remap_decls (BIND_EXPR_VARS (*tp), NULL, id); + { + tree t; + + /* This will remap a lot of the same decls again, but this should be + harmless. */ + BIND_EXPR_VARS (*tp) = remap_decls (BIND_EXPR_VARS (*tp), NULL, id); + + /* Also copy value-expressions. */ + for (t = BIND_EXPR_VARS (*tp); t; t = TREE_CHAIN (t)) + if (TREE_CODE (t) == VAR_DECL + && DECL_HAS_VALUE_EXPR_P (t)) + { + tree tem = DECL_VALUE_EXPR (t); + walk_tree (&tem, copy_tree_body_r, id, NULL); + SET_DECL_VALUE_EXPR (t, tem); + } + } } -- cgit v1.2.1 From 799c87118f9c74e999ba3f3390edc6a5346c8752 Mon Sep 17 00:00:00 2001 From: jamborm Date: Wed, 28 Apr 2010 14:05:54 +0000 Subject: 2010-04-28 Martin Jambor * cgraph.h (struct cgraph_node): New field indirect_calls. (struct cgraph_indirect_call_info): New type. (struct cgraph_edge): Removed field indirect_call. New fields indirect_info, indirect_inlining_edge and indirect_unknown_callee. (cgraph_create_indirect_edge): Declare. (cgraph_make_edge_direct): Likewise. (enum LTO_cgraph_tags): New item LTO_cgraph_indirect_edge. * ipa-prop.h (struct ipa_param_call_note): Removed. (struct ipa_node_params): Removed field param_calls. (ipa_create_all_structures_for_iinln): Declare. * cgraph.c: Described indirect edges and uids in initial comment. (cgraph_add_edge_to_call_site_hash): New function. (cgraph_edge): Search also among the indirect edges, use cgraph_add_edge_to_call_site_hash to add edges to the call site hash. (cgraph_set_call_stmt): Possibly turn an indirect edge into a direct one, use cgraph_add_edge_to_call_site_hash to add edges to the call site hash. (initialize_inline_failed): Assign a reason to indirect edges. (cgraph_create_edge_1): New function. (cgraph_create_edge): Moved some functionality to cgraph_create_edge_1. (cgraph_create_indirect_edge): New function. (cgraph_edge_remove_callee): Add an assert checking for non-indirectness. (cgraph_edge_remove_caller): Special-case indirect edges. (cgraph_remove_edge): Likewise. (cgraph_set_edge_callee): New function. (cgraph_redirect_edge_callee): Use cgraph_set_edge_callee. (cgraph_make_edge_direct): New function. (cgraph_update_edges_for_call_stmt_node): Do nothing only when also the declaration of the call statement matches. (cgraph_node_remove_callees): Special-case indirect edges. (cgraph_clone_edge): Likewise. (cgraph_clone_node): Clone also the indirect edges. (dump_cgraph_node): Dump indirect_inlining_edge flag instead of indirect_call, dump count of indirect_calls edges. * ipa-prop.c (iinlining_processed_edges): New variable. (ipa_note_param_call): Create indirect edges instead of creating notes. New parameter node. (ipa_analyze_call_uses): New parameter node, pass it on to ipa_note_param_call. (ipa_analyze_stmt_uses): Likewise. (ipa_analyze_params_uses): Pass node to ipa_analyze_stmt_uses. (print_edge_addition_message): Work on edges rather than on notes. (update_call_notes_after_inlining): Likewise, renamed to update_indirect_edges_after_inlining. (ipa_create_all_structures_for_iinln): New function. (ipa_free_node_params_substructures): Do not free notes. (ipa_edge_duplication_hook): Propagate bits within iinlining_processed_edges bitmap. (ipa_node_duplication_hook): Do not duplicate notes. (free_all_ipa_structures_after_ipa_cp): Renamed to ipa_free_all_structures_after_ipa_cp. (free_all_ipa_structures_after_iinln): Renamed to ipa_free_all_structures_after_iinln.g (ipa_write_param_call_note): Removed. (ipa_read_param_call_note): Removed. (ipa_write_indirect_edge_info): New function. (ipa_read_indirect_edge_info): Likewise. (ipa_write_node_info): Do not stream notes, do stream information in indirect edges. (ipa_read_node_info): Likewise. (lto_ipa_fixup_call_notes): Removed. * ipa-cp.c (pass_ipa_cp): Set stmt_fixup to NULL. * ipa-inline.c (pass_ipa_inline): Likewise. * cgraphunit.c (verify_cgraph_node): Check also indirect edges. * cif-code.def (INDIRECT_UNKNOWN_CALL): New reason. * tree-inline.c (copy_bb): Removed an unnecessary double check for is_gimple_call. * tree-inline.c (get_indirect_callee_fndecl): Do not consider indirect edges. * lto-cgraph.c (output_outgoing_cgraph_edges): New function. (output_cgraph): Stream also indirect edges. (lto_output_edge): Added capability to stream indirect edges. (input_edge): Likewise. (input_cgraph_1): Likewise. * testsuite/gcc.dg/lto/20091209-1_0.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158827 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 7f35c4d60ca..383cc86f243 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1698,9 +1698,8 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* Constant propagation on argument done during inlining may create new direct call. Produce an edge for it. */ if ((!edge - || (edge->indirect_call + || (edge->indirect_inlining_edge && id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)) - && is_gimple_call (stmt) && (fn = gimple_call_fndecl (stmt)) != NULL) { struct cgraph_node *dest = cgraph_node (fn); @@ -3553,7 +3552,7 @@ get_indirect_callee_fndecl (struct cgraph_node *node, gimple stmt) struct cgraph_edge *cs; cs = cgraph_edge (node, stmt); - if (cs) + if (cs && !cs->indirect_unknown_callee) return cs->callee->decl; return NULL_TREE; @@ -3636,7 +3635,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) /* If this call was originally indirect, we do not want to emit any inlining related warnings or sorry messages because there are no guarantees regarding those. */ - if (cg_edge->indirect_call) + if (cg_edge->indirect_inlining_edge) goto egress; if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) -- cgit v1.2.1 From 3912327b9151d79abcb95a324185c179f75d93ef Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 10 May 2010 08:55:32 +0000 Subject: 2010-05-10 Richard Guenther PR tree-optimization/44050 * tree-inline.c (tree_function_versioning): Clone the ipa-pta flag. * gcc.dg/torture/pr44050.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159214 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 383cc86f243..8e7d1d67614 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4924,6 +4924,8 @@ tree_function_versioning (tree old_decl, tree new_decl, (DECL_STRUCT_FUNCTION (old_decl)); initialize_cfun (new_decl, old_decl, old_entry_block->count); + DECL_STRUCT_FUNCTION (new_decl)->gimple_df->ipa_pta + = id.src_cfun->gimple_df->ipa_pta; push_cfun (DECL_STRUCT_FUNCTION (new_decl)); /* Copy the function's static chain. */ -- cgit v1.2.1 From ea7e866e878831ed073b7160e8b5707676abba2e Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 11 May 2010 08:14:50 +0000 Subject: * cgraphbuild.c (cgraph_rebuild_references): New. (cgraph_mark_reachable_node): Accept references to optimized out extern inlines. * cgraph.h (cgraph_rebuild_references): Declare. * tree-inline.c (tree_function_versioning): Use it. * ipa-struct-reorg.c (do_reorg_for_func): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159259 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 8e7d1d67614..ee7a45712df 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -5037,6 +5037,8 @@ tree_function_versioning (tree old_decl, tree new_decl, pointer_set_destroy (id.statements_to_fold); fold_cond_expr_cond (); delete_unreachable_blocks_update_callgraph (&id); + if (id.dst_node->analyzed) + cgraph_rebuild_references (); update_ssa (TODO_update_ssa); free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); -- cgit v1.2.1 From 6f932b06df8837c89ebb97e12c497f86d08b7f60 Mon Sep 17 00:00:00 2001 From: hubicka Date: Wed, 12 May 2010 13:49:34 +0000 Subject: * cgraph.h (struct varpool_node): Add aux. * varasm.c (find_decl_and_mark_needed): Force output of varpool nodes. * varpool.c (varpool_remove_node): Do not remove initializer. (varpool_reset_queue): Export. (varpool_finalize_decl): Volatile vars are forced to be output. * lto-symtab.c (lto_varpool_replace_node): Clear out initializer of replaced decl. * ipa.c (enqueue_cgraph_node, enqueue_varpool_node, process_references, varpool_can_remove_if_no_refs): New functions. (cgraph_remove_unreachable_nodes): Handle variables too. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159321 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ee7a45712df..302d36b9f34 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -688,7 +688,7 @@ copy_bind_expr (tree *tp, int *walk_subtrees, copy_body_data *id) /* Create a new gimple_seq by remapping all the statements in BODY using the inlining information in ID. */ -gimple_seq +static gimple_seq remap_gimple_seq (gimple_seq body, copy_body_data *id) { gimple_stmt_iterator si; -- cgit v1.2.1 From cdedc7400d8cfdcd7517180421ae4cc3b636d806 Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 13 May 2010 06:13:46 +0000 Subject: * cgraph.c (cgraph_mark_address_taken_node): No longer imply needed flag. * cgraph.h (cgraph_only_called_directly_p, cgraph_can_remove_if_no_direct_calls_p): test address_taken flag. (cgraph_can_remove_if_no_direct_calls_and_refs_p): New function. * cgraphunit.c (cgraph_mark_functions_to_output): Test address_taken. (assemble * ipa.c (cgraph_remove_unreachable_nodes): Use cgraph_can_remove_if_no_direct_calls_and_refs_p; clear address_taken flags. * tree-inline.c (copy_bb): Check address_taken flag. * tree-profile.c (tree_gen_ic_func_profiler): Check address_taken and externally_visible flag. * tree-ssa/unreachable.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159354 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 302d36b9f34..03b013cbde6 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1711,6 +1711,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, other cases we hit a bug (incorrect node sharing is the most common reason for missing edges). */ gcc_assert (dest->needed || !dest->analyzed + || dest->address_taken || !id->src_node->analyzed); if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES) cgraph_create_edge_including_clones -- cgit v1.2.1 From 1bf41320ebc2b9427bda2813998eb2e869d4d0f4 Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 17 May 2010 23:02:47 +0000 Subject: * cgraph.h (struct ipa_replace_map): Add parm_num parameter. * lto-cgraph.c (output_cgraph_opt_summary, input_cgraph_opt_summary): New functions. (output_cgraph): Call output_cgraph_opt_summary. (input_cgrpah): Call input_cgraph_opt_summary. (output_cgraph_opt_summary_p, output_node_opt_summary, input_node_opt_summary, input_cgraph_opt_section): New functions. * lto-section-in.c (lto_section_name): Add cgraphopt. * tree-inline.c (tree_function_versioning): Handle parm_num. * lto-streamer.c (lto_get_section_name): Handle cgraphopt. * lto-streamer.h (lto_section_type): Add LTO_section_cgraph_opt_sum. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159517 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 03b013cbde6..bb2ee237ff3 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4945,6 +4945,15 @@ tree_function_versioning (tree old_decl, tree new_decl, if (replace_info->replace_p) { tree op = replace_info->new_tree; + if (!replace_info->old_tree) + { + int i = replace_info->parm_num; + tree parm; + for (parm = DECL_ARGUMENTS (old_decl); i; parm = TREE_CHAIN (parm)) + i --; + replace_info->old_tree = parm; + } + STRIP_NOPS (op); -- cgit v1.2.1 From a7a4626828090600459358ca745c4482cf9551a1 Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 21 May 2010 13:53:22 +0000 Subject: gcc/ChangeLog: * tree.h: Include real.h and fixed-value.h as basic datatypes. * dfp.c, convert.c, reload1.c, reginfo.c, tree-flow.h, tree-ssa-threadedge.c, tree-ssanames.c, tree-loop-linear.c, tree-into-ssa.c, tree-vect-generic.c, tree-ssa-structalias.c, tree-ssa-loop-im.c, tree-dump.c, tree-complex.c, tree-ssa-uninit.c, genrecog.c, tree-ssa-threadupdate.c, tree-ssa-loop-niter.c, tree-pretty-print.c, tree-loop-distribution.c, tree-ssa-loop-unswitch.c, c-lex.c, optabs.c, postreload-gcse.c, tree-ssa-loop-manip.c, postreload.c, tree-ssa-loop-ch.c, tree-tailcall.c, tree.c, reload.c, tree-scalar-evolution.c, rtlanal.c, tree-phinodes.c, builtins.c, final.c, genoutput.c, fold-const.c, tree-ssa-dse.c, genautomata.c, tree-ssa-uncprop.c, toplev.c, tree-chrec.c, genemit.c, c-cppbuiltin.c, tree-ssa-sccvn.c, tree-ssa-ccp.c, tree-ssa-loop-ivopts.c, mode-switching.c, tree-call-cdce.c, cse.c, genpeep.c, tree-ssa-math-opts.c, tree-ssa-dom.c, tree-nrv.c, tree-ssa-propagate.c, tree-ssa-alias.c, tree-ssa-sink.c, jump.c, ifcvt.c, dwarf2out.c, expr.c, genattrtab.c, genconditions.c, tree-ssa-loop-ivcanon.c, tree-ssa-loop.c, tree-parloops.c, recog.c, tree-ssa-address.c, lcm.c, tree-eh.c, gimple-pretty-print.c, c-pretty-print.c, print-rtl.c, gcse.c, tree-if-conv.c, tree-data-ref.c, tree-affine.c, gimplify.c, tree-ssa-phiopt.c, implicit-zee.c, expmed.c, tree-dfa.c, emit-rtl.c, store-motion.c, cselib.c, tree-cfgcleanup.c, simplify-rtx.c, tree-ssa-pre.c, genpreds.c, tree-mudflap.c, print-tree.c, tree-ssa-copy.c, tree-ssa-forwprop.c, tree-ssa-dce.c, varasm.c, tree-nested.c, tree-ssa.c, tree-ssa-loop-prefetch.c, rtl.c, tree-inline.c, integrate.c, tree-optimize.c, tree-ssa-phiprop.c, fixed-value.c, combine.c, tree-profile.c, c-common.c, sched-vis.c, tree-cfg.c, passes.c, tree-ssa-reassoc.c, config/alpha/alpha.c, config/frv/frv.c, config/s390/s390.c, config/m32c/m32c.c, config/spu/spu.c, config/sparc/sparc.c, config/mep/mep.c, config/m32r/m32r.c, config/rx/rx.c, config/i386/i386.c, config/sh/sh.c, config/pdp11/pdp11.c, config/avr/avr.c, config/crx/crx.c, config/xtensa/xtensa.c, config/stormy16/stormy16.c, config/fr30/fr30.c, config/lm32/lm32.c, config/moxie/moxie.c, config/m68hc11/m68hc11.c, config/cris/cris.c, config/iq2000/iq2000.c, config/mn10300/mn10300.c, config/ia64/ia64.c, config/m68k/m68k.c, config/rs6000/rs6000.c, config/picochip/picochip.c, config/darwin.c, config/arc/arc.c, config/mcore/mcore.c, config/score/score3.c, config/score/score7.c, config/score/score.c, config/arm/arm.c, config/pa/pa.c, config/mips/mips.c, config/vax/vax.c, config/h8300/h8300.c, config/v850/v850.c, config/mmix/mmix.c, config/bfin/bfin.c: Clean up redundant includes. * Makefile.in: Update accordingly. java/ChangeLog: * typeck.c, decl.c, jcf-parse.c, except.c, expr.c: cp/Changelog: * error.c, tree.c, typeck2.c, cxx-pretty-print.c, mangle.c: Clean up redundant includes. fortran/ChangeLog: * trans-const.c, trans-types.c, trans-intrinsic.c: Clean up redundant includes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159663 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index bb2ee237ff3..468aa011daa 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -26,7 +26,6 @@ along with GCC; see the file COPYING3. If not see #include "toplev.h" #include "tree.h" #include "tree-inline.h" -#include "rtl.h" #include "expr.h" #include "flags.h" #include "params.h" -- cgit v1.2.1 From ce084dfc1cd60d867d38dbed86a914d82fa908d1 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Fri, 21 May 2010 22:34:26 +0000 Subject: * diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or langhooks-def.h. (diagnostic_initialize): Initialize x_data not last_function. (diagnostic_report_current_function): Move to tree-diagnostic.c. (default_diagnostic_starter): Call diagnostic_report_current_module not diagnostic_report_current_function. (diagnostic_report_diagnostic): Initialize x_data not abstract_origin. (verbatim): Likewise. * diagnostic.h (struct diagnostic_info): Change abstract_origin to x_data. (struct diagnostic_context): Change last_function to x_data. (diagnostic_auxiliary_data): Replace with diagnostic_context_auxiliary_data and diagnostic_info_auxiliary_data. (diagnostic_last_function_changed, diagnostic_set_last_function, diagnostic_report_current_function): Move to tree-diagnostic.h. (print_declaration, dump_generic_node, print_generic_stmt, print_generic_stmt_indented, print_generic_expr, print_generic_decl, debug_c_tree, dump_omp_clauses, print_call_name, debug_generic_expr, debug_generic_stmt, debug_tree_chain, default_tree_printer): Move to tree-pretty-print.h. (debug_gimple_stmt, debug_gimple_seq, print_gimple_seq, print_gimple_stmt, print_gimple_expr, dump_gimple_stmt): Move to gimple-pretty-print.h. * pretty-print.c: Don't include tree.h (pp_base_format): Don't handle %K here. (pp_base_tree_identifier): Move to tree-pretty-print.c. * pretty-print.h (text_info): Change abstract_origin to x_data. (pp_tree_identifier, pp_unsupported_tree, pp_base_tree_identifier): Move to tree-pretty-print.h. * gimple-pretty-print.h, tree-diagnostic.c, tree-diagnostic.h, tree-pretty-print.h: New files. * tree-pretty-print.c: Include tree-pretty-print.h. (percent_K_format): New. Moved from pretty-print.c. (pp_base_tree_identifier): Move from pretty-print.c. * c-objc-common.c: Include tree-pretty-print.h. (c_tree_printer): Handle %K here. * langhooks.c: Include tree-diagnostic.h. (lhd_print_error_function): Use diagnostic_abstract_origin macro. * toplev.c: Include tree-diagnostic.h and tree-pretty-print.h. (default_tree_printer): Handle %K using percent_K_format. (general_init): Use default_tree_diagnostic_starter. * tree.c: Include tree-diagnostic.h and tree-pretty-print.h. (free_lang_data): Use default_tree_diagnostic_starter. * c-pretty-print.c: Include tree-pretty-print.h. * cfgexpand.c: Include tree-pretty-print.h and gimple-pretty-print.h. * cgraphunit.c: Include tree-pretty-print.h and gimple-pretty-print.h. * dwarf2out.c: Include tree-pretty-print.h. * except.c: Include tree-pretty-print.h. * gimple-pretty-print.c: Include tree-pretty-print.h and gimple-pretty-print.h. * gimplify.c: Include tree-pretty-print.h. * graphite-poly.c: Include tree-pretty-print.h and gimple-pretty-print.h. * ipa-cp.c: Include tree-pretty-print.h. * ipa-inline.c: Include gimple-pretty-print.h. * ipa-prop.c: Include tree-pretty-print.h and gimple-pretty-print.h. * ipa-pure-const.c: Include gimple-pretty-print.h. * ipa-struct-reorg.c: Include tree-pretty-print.h and gimple-pretty-print.h. * ipa-type-escape.c: Include tree-pretty-print.h. * print-rtl.c: Include tree-pretty-print.h. * print-tree.c: Include gimple-pretty-print.h. * sese.c: Include tree-pretty-print.h. * tree-affine.c: Include tree-pretty-print.h. * tree-browser.c: Include tree-pretty-print.h. * tree-call-cdce.c: Include gimple-pretty-print.h. * tree-cfg.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-chrec.c: Include tree-pretty-print.h. * tree-data-ref.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-dfa.c: Include tree-pretty-print.h. * tree-if-conv.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-inline.c: Include tree-pretty-print.h. * tree-into-ssa.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-nrv.c: Include tree-pretty-print.h. * tree-object-size.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-outof-ssa.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-parloops.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-predcom.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-scalar-evolution.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-sra.c: Include tree-pretty-print.h. * tree-ssa-address.c: Include tree-pretty-print.h. * tree-ssa-alias.c: Include tree-pretty-print.h. * tree-ssa-ccp.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-coalesce.c: Include tree-pretty-print.h. * tree-ssa-copy.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-copyrename.c: Include tree-pretty-print.h. * tree-ssa-dce.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-dom.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-dse.c: Include gimple-pretty-print.h. * tree-ssa-forwprop.c: Include tree-pretty-print.h. * tree-ssa-ifcombine.c: Include tree-pretty-print.h. * tree-ssa-live.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-im.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-ivcanon.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-ivopts.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-niter.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-prefetch.c: Include tree-pretty-print.h. * tree-ssa-math-opts.c: Include gimple-pretty-print.h. * tree-ssa-operands.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-phiprop.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-pre.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-propagate.c: Include gimple-pretty-print.h. * tree-ssa-reassoc.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-sccvn.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-sink.c: Include gimple-pretty-print.h. * tree-ssa-ter.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-uninit.c: Include gimple-pretty-print.h. * tree-ssa.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-stdarg.c: Include gimple-pretty-print.h. * tree-switch-conversion.c: Include gimple-pretty-print.h. * tree-tailcall.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-data-refs.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-loop-manip.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-loop.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-patterns.c: Include gimple-pretty-print.h. * tree-vect-slp.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-stmts.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vectorizer.c: Include tree-pretty-print.h. * tree-vrp.c: Include tree-pretty-print.h and gimple-pretty-print.h. * value-prof.c: Include tree-pretty-print.h and gimple-pretty-print.h. * var-tracking.c: Include tree-pretty-print.h. * Makefile.in (OBJS-common): Add tree-diagnostic.o. (tree-diagnostic.o): New dependencies. (c-objc-common.o, c-pretty-print.o, langhooks.o, tree.o, tree-inline.o, print-tree.o, stor-layout.o, tree-ssa-uninit.o, tree-ssa.o, tree-into-ssa.o, tree-ssa-ter.o, tree-ssa-coalesce.o, tree-outof-ssa.o, tree-ssa-forwprop.o, tree-ssa-phiprop.o, tree-ssa-ifcombine.o, tree-nrv.o, tree-ssa-copy.o, tree-ssa-propagate.o, tree-ssa-dom.o, tree-ssa-uncprop.o, tree-ssa-live.o, tree-ssa-copyrename.o, tree-ssa-pre.o, tree-ssa-sccvn.o, tree-vrp.o, tree-cfg.o, tree-tailcall.o, tree-ssa-sink.o, tree-if-conv.o, tree-dfa.o, tree-ssa-operands.o, tree-ssa-address.o, tree-ssa-loop-niter.o, tree-ssa-loop-ivcanon.o, tree-ssa-loop-prefetch.o, tree-predcom.o, tree-ssa-loop-ivopts.o, tree-affine.o, tree-ssa-loop-im.o, tree-ssa-math-opts.o, tree-ssa-alias.o, tree-ssa-reassoc.o, gimplify.o, tree-browser.o, tree-chrec.o, tree-scalar-evolution.o, tree-data-ref.o, sese.o, graphite-poly.o, tree-vect-loop.o, tree-vect-loop-manip.o, tree-vect-patterns.o, tree-vect-slp.o, tree-vect-stmts.o, tree-vect-data-refs.o, tree-vectorizer.o, tree-parloops.o, tree-stdarg.o, tree-object-size.o, gimple-pretty-print.o, tree-pretty-print.o, diagnostic.o, toplev.o, print-rtl.o, except.o, dwarf2out.o, cgraphunit.o, ipa-prop.o, ipa-cp.o, ipa-inline.o, ipa-pure-const.o, ipa-type-escape.o, ipa-struct-reorg.o, tree-ssa-dce.o, tree-call-cdce.o, tree-ssa-ccp.o, tree-sra.o, tree-switch-conversion.o, var-tracking.o, value-prof.o, cfgexpand.o, pretty-print.o): Update dependencies. cp: * error.c: Include tree-diagnostic.h and tree-pretty-print.h. (cp_print_error_function): Use diagnostic_abstract_origin macro. (cp_printer): Handle %K here using percent_K_format. * cxx-pretty-print.c: Include tree-pretty-print.h. * Make-lang.in (cp/error.o, cp/cxx-pretty-print.o): Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159685 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 468aa011daa..4c51f3b10c8 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "function.h" #include "tree-flow.h" #include "diagnostic.h" +#include "tree-pretty-print.h" #include "except.h" #include "debug.h" #include "pointer-set.h" -- cgit v1.2.1 From cd3ece5320bbe2462d7f17d39ae81e0398f2c252 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 25 May 2010 16:15:38 +0000 Subject: PR debug/42801 * tree-inline.c (remap_decls): Remap DECL_VALUE_EXPR here... (copy_bind_expr): ... instead of here. (copy_tree_body_r): If id->remapping_type_depth clear TREE_BLOCK if the block hasn't been remapped. * dwarf2out.c (gen_formal_parameter_die, gen_variable_die): When emitting concrete instance of abstract VLA, add DW_AT_type attribute. * gcc.dg/guality/sra-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159826 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 4c51f3b10c8..342b5a5f082 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -574,6 +574,19 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) gcc_assert (DECL_P (new_var)); TREE_CHAIN (new_var) = new_decls; new_decls = new_var; + + /* Also copy value-expressions. */ + if (TREE_CODE (new_var) == VAR_DECL + && DECL_HAS_VALUE_EXPR_P (new_var)) + { + tree tem = DECL_VALUE_EXPR (new_var); + bool old_regimplify = id->regimplify; + id->remapping_type_depth++; + walk_tree (&tem, copy_tree_body_r, id, NULL); + id->remapping_type_depth--; + id->regimplify = old_regimplify; + SET_DECL_VALUE_EXPR (new_var, tem); + } } } @@ -665,23 +678,9 @@ copy_bind_expr (tree *tp, int *walk_subtrees, copy_body_data *id) } if (BIND_EXPR_VARS (*tp)) - { - tree t; - - /* This will remap a lot of the same decls again, but this should be - harmless. */ - BIND_EXPR_VARS (*tp) = remap_decls (BIND_EXPR_VARS (*tp), NULL, id); - - /* Also copy value-expressions. */ - for (t = BIND_EXPR_VARS (*tp); t; t = TREE_CHAIN (t)) - if (TREE_CODE (t) == VAR_DECL - && DECL_HAS_VALUE_EXPR_P (t)) - { - tree tem = DECL_VALUE_EXPR (t); - walk_tree (&tem, copy_tree_body_r, id, NULL); - SET_DECL_VALUE_EXPR (t, tem); - } - } + /* This will remap a lot of the same decls again, but this should be + harmless. */ + BIND_EXPR_VARS (*tp) = remap_decls (BIND_EXPR_VARS (*tp), NULL, id); } @@ -1116,8 +1115,9 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) tree *n; n = (tree *) pointer_map_contains (id->decl_map, TREE_BLOCK (*tp)); - gcc_assert (n); - new_block = *n; + gcc_assert (n || id->remapping_type_depth != 0); + if (n) + new_block = *n; } TREE_BLOCK (*tp) = new_block; } -- cgit v1.2.1 From cbeb677e2ce01e4bae1d9af26ac91d9eb839507d Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Tue, 25 May 2010 22:34:36 +0000 Subject: * function.h (struct function): Add can_throw_non_call_exceptions bit. * lto-streamer-in.c (input_function): Stream it in. * lto-streamer-out.c (output_function): Stream it out. * function.c (allocate_struct_function): Set it. (expand_function_end): Substitute cfun->can_throw_non_call_exceptions for flag_non_call_exceptions. * cfgbuild.c (control_flow_insn_p): Likewise. (make_edges): Likewise. * cfgexpand.c (expand_stack_alignment): Likewise. * combine.c (distribute_notes): Likewise. * cse.c (cse_extended_basic_block): Likewise. * except.c (insn_could_throw_p): Likewise. * gcse.c (simple_mem): Likewise. * ipa-pure-const.c (check_call): Likewise. (check_stmt ): Likewise. * lower-subreg.c (lower-subreg.c): Likewise. * optabs.c (emit_libcall_block): Likewise. (prepare_cmp_insn): Likewise. * postreload-gcse.c (eliminate_partially_redundant_loads): Likewise. * postreload.c (rest_of_handle_postreload): Likewise. * reload1.c (reload_as_needed): Likewise. (emit_input_reload_insns): Likewise. (emit_output_reload_insns): Likewise. (fixup_abnormal_edges): Likewise. * sel-sched-ir.c (init_global_and_expr_for_insn): Likewise. * store-motion.c (find_moveable_store): Likewise. * tree-eh.c (stmt_could_throw_p): Likewise. (tree_could_throw_p): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise. * config/arm/arm.c (arm_expand_prologue): Likewise. (thumb1_expand_prologue): Likewise. * config/rx/rx.md (cbranchsf4): Likewise. (cmpsf): Likewise. * config/s390/s390.c (s390_emit_prologue): Likewise. * tree-inline.c (initialize_cfun): Copy can_throw_non_call_exceptions. (inline_forbidden_into_p): New predicate. (expand_call_inline): Use it to forbid inlining. (tree_can_inline_p): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159847 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 342b5a5f082..697c6bc269a 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2028,6 +2028,8 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count) cfun->stdarg = src_cfun->stdarg; cfun->dont_save_pending_sizes_p = src_cfun->dont_save_pending_sizes_p; cfun->after_inlining = src_cfun->after_inlining; + cfun->can_throw_non_call_exceptions + = src_cfun->can_throw_non_call_exceptions; cfun->returns_struct = src_cfun->returns_struct; cfun->returns_pcc_struct = src_cfun->returns_pcc_struct; cfun->after_tree_profile = src_cfun->after_tree_profile; @@ -2960,6 +2962,29 @@ inline_forbidden_p (tree fndecl) return forbidden_p; } +/* Return true if CALLEE cannot be inlined into CALLER. */ + +static bool +inline_forbidden_into_p (tree caller, tree callee) +{ + /* Don't inline if the functions have different EH personalities. */ + if (DECL_FUNCTION_PERSONALITY (caller) + && DECL_FUNCTION_PERSONALITY (callee) + && (DECL_FUNCTION_PERSONALITY (caller) + != DECL_FUNCTION_PERSONALITY (callee))) + return true; + + /* Don't inline if the callee can throw non-call exceptions but the + caller cannot. */ + if (DECL_STRUCT_FUNCTION (callee) + && DECL_STRUCT_FUNCTION (callee)->can_throw_non_call_exceptions + && !(DECL_STRUCT_FUNCTION (caller) + && DECL_STRUCT_FUNCTION (caller)->can_throw_non_call_exceptions)) + return true; + + return false; +} + /* Returns nonzero if FN is a function that does not have any fundamental inline blocking properties. */ @@ -3622,15 +3647,11 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) cg_edge = cgraph_edge (id->dst_node, stmt); - /* Don't inline functions with different EH personalities. */ - if (DECL_FUNCTION_PERSONALITY (cg_edge->caller->decl) - && DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl) - && (DECL_FUNCTION_PERSONALITY (cg_edge->caller->decl) - != DECL_FUNCTION_PERSONALITY (cg_edge->callee->decl))) + /* First check that inlining isn't simply forbidden in this case. */ + if (inline_forbidden_into_p (cg_edge->caller->decl, cg_edge->callee->decl)) goto egress; - /* Don't try to inline functions that are not well-suited to - inlining. */ + /* Don't try to inline functions that are not well-suited to inlining. */ if (!cgraph_inline_p (cg_edge, &reason)) { /* If this call was originally indirect, we do not want to emit any @@ -5180,12 +5201,8 @@ tree_can_inline_p (struct cgraph_edge *e) caller = e->caller->decl; callee = e->callee->decl; - /* We cannot inline a function that uses a different EH personality - than the caller. */ - if (DECL_FUNCTION_PERSONALITY (caller) - && DECL_FUNCTION_PERSONALITY (callee) - && (DECL_FUNCTION_PERSONALITY (caller) - != DECL_FUNCTION_PERSONALITY (callee))) + /* First check that inlining isn't simply forbidden in this case. */ + if (inline_forbidden_into_p (caller, callee)) { e->inline_failed = CIF_UNSPECIFIED; gimple_call_set_cannot_inline (e->call_stmt, true); -- cgit v1.2.1 From 852f689eb9b7f6d7aafc2f72007e96129ac9bd45 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Thu, 27 May 2010 20:16:07 +0000 Subject: * diagnostic-core.h: New. Contents moved from diagnostic.h and toplev.h. * diagnostic.c: Don't include toplev.h. (progname): Define. Moved from toplev.c. (seen_error): New function. * diagnostic.h: Include diagnostic-core.h. (diagnostic_t, emit_diagnostic): Don't declare here. * toplev.c (progname): Move to toplev.c. (emit_debug_global_declarations, compile_file, finalize, do_compile, toplev_main): Use seen_error. * toplev.h: Include diagnostic-core.h. (trim_filename, GCC_DIAG_STYLE, ATTRIBUTE_GCC_DIAG, internal_error, warning, warning_at, error, error_n, error_at, fatal_error, pedwarn, permerror, sorry, inform, inform_n, verbatim, fnotice, progname): Move to diagnostic-core.h. * builtins.c: Include diagnostic-core.h instead of diagnostic.h. (expand_builtin_expect): Use seen_error. * c-decl.c: Include diagnostic-core.h instead of diagnostic.h. (c_make_fname_decl, c_write_global_declarations): Use seen_error. * c-format.c: Include diagnostic-core.h instead of diagnostic.h. * c-gimplify.c: Include diagnostic-core.h instead of diagnostic.h. * c-lang.c: Include diagnostic-core.h instead of diagnostic.h. * c-lex.c (c_lex_with_flags, interpret_float): Don't increment errorcount for errors. * c-opts.c (c_common_finish): Use seen_error. * cgraph.c: Include diagnostic-core.h instead of diagnostic.h. * cgraphunit.c (verify_cgraph_node, verify_cgraph, cgraph_output_pending_asms, cgraph_optimize): Use seen_error. * coverage.c: Include diagnostic-core.h instead of diagnostic.h. (get_coverage_counts): Use seen_error. * dwarf2out.c (dwarf2out_finish): Use seen_error. * gimplify.c (gimplify_var_or_parm_decl, gimple_push_cleanup, gimplify_body): Use seen_error. * ipa-inline.c (cgraph_early_inlining): Use seen_error. * ipa-pure-const.c (gate_pure_const): Use seen_error. * ipa-reference.c (gate_reference): Use seen_error. * jump.c: Include diagnostic-core.h instead of diagnostic.h. * lambda-code.c: Include diagnostic-core.h instead of diagnostic.h. * lto-cgraph.c: Include diagnostic-core.h instead of diagnostic.h. * lto-compress.c: Include diagnostic-core.h instead of diagnostic.h. * lto-section-in.c: Include diagnostic-core.h instead of diagnostic.h. * lto-streamer-out.c: Include diagnostic-core.h instead of diagnostic.h. * lto-streamer.c: Include diagnostic-core.h instead of diagnostic.h. (gate_lto_out): Use seen_error. * matrix-reorg.c: Include diagnostic-core.h instead of diagnostic.h. * omega.c: Include diagnostic-core.h instead of diagnostic.h. * omp-low.c: Include diagnostic-core.h instead of diagnostic.h. (gate_expand_omp, lower_omp_1): Use seen_error. * passes.c: Include diagnostic-core.h instead of diagnostic.h. (rest_of_decl_compilation, rest_of_type_compilation, gate_rest_of_compilation, ipa_write_summaries): Use seen_error. * tree-cfg.c (label_to_block_fn): Use seen_error. * tree-inline.c (optimize_inline_calls): Use seen_error. * tree-mudflap.c (mudflap_finish_file): Use seen_error. * tree-optimize.c (gate_all_optimizations, gate_all_early_local_passes, gate_all_early_optimizations): Use seen_error. * tree-ssa-structalias.c (gate_ipa_pta): Use seen_error. * varpool.c: Include diagnostic-core.h instead of diagnostic.h. (varpool_remove_unreferenced_decls, varpool_assemble_pending_decls): Use seen_error. * Makefile.in (DIAGNOSTIC_CORE_H): Define. (TOPLEV_H, DIAGNOSTIC_H): Update. (c-decl.o, c-lang.o, c-format.o, lto-compress.o, lto-cgraph.o, lto-streamer-out.o, lto-section-in.o, lto-streamer.o, c-gimplify.o, omp-low.o, omega.o, diagnostic.o, passes.o, builtins.o, jump.o, cgraph.o, varpool.o, matrix-reorg.o, coverage.o, lambda-code.o): Update dependencies. cp: * call.c: Include diagnostic-core.h instead of diagnostic.h. * cp-lang.c: Don't include diagnostic.h * name-lookup.c: Include diagnostic-core.h instead of diagnostic.h. (cp_emit_debug_info_for_using): Use seen_error. * optimize.c: Include diagnostic-core.h instead of diagnostic.h. * parser.c: Include diagnostic-core.h instead of diagnostic.h. * pt.c (iterative_hash_template_arg): Use seen_error. * repo.c: Include diagnostic-core.h instead of diagnostic.h. * typeck2.c: Include diagnostic-core.h instead of diagnostic.h. * Make-lang.in (cp/cp-lang.o, cp/typeck2.o, cp/call.o, cp/repo.o, cp/optimize.o, cp/parser.o, cp/name-lookup.o): Update dependencies. lto: * lto.c: Include diagnostic-core.h instead of diagnostic.h. (read_cgraph_and_symbols, lto_main): Use seen_error. * Make-lang.in (lto/lto.o): Update dependencies. objc: * objc-act.c: Include diagnostic-core.h instead of diagnostic.h. * Make-lang.in (objc/objc-act.o): Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159947 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 697c6bc269a..a70c09fb3f5 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4060,7 +4060,7 @@ optimize_inline_calls (tree fn) /* There is no point in performing inlining if errors have already occurred -- and we might crash if we try to inline invalid code. */ - if (errorcount || sorrycount) + if (seen_error ()) return 0; /* Clear out ID. */ -- cgit v1.2.1 From 4b987facd8ba658d00c277a7e9c46548b492854f Mon Sep 17 00:00:00 2001 From: hubicka Date: Sat, 29 May 2010 20:31:45 +0000 Subject: * tree-vrp.c (debug_value_range, debug_all_value_ranges, debug_asserts_for, debug_all_asserts): Annotate with DEBUG_FUNCTION. * tree-into-ssa.c (debug_decl_set, debug_defs_stack, debug_currdefs, debug_tree_ssa, debug_tree_ssa_stats, debug_def_blocks, debug_names_replaced_by, debug_update_ssa): Likewise. * sbitmap.c (debug_sbitmap): Likewise. * genrecog.c (debug_decision, debug_decision_list): Likewise. * tree-pretty-print.c (debug_generic_expr, debug_generic_stmt, debug_tree_chain): Likewise. * tree-loop-distribution.c (debug_rdg_partitions): Likewise. * cgraph.c (debug_cgraph_node, debug_cgraph): Likewise. * optabs.c (debug_optab_libfuncs): Likewise. (verify_loop_closed_ssa): Likewise. * value-prof.c (verify_histograms): Likewise. * reload.c (debug_reload_to_stream, debug_reload): Likewise. * bitmap.c (debug_bitmap_file, debug_bitmap, bitmap_print): Likewise. * cfghooks.c (verify_flow_info): Likewise. * fold-const.c (debug_fold_checksum): Likewise. * omp-low.c (debug_omp_region, debug_all_omp_regions): Likewise. * cfg.c (debug_regset, debug_flow_info, debug_bb, debug_bb_n): Likewise. * omega.c (debug_omega_problem): Likewise. * cgraphunit.c (verify_cgraph_node, verify_cgraph): Likewise. * tree-ssa-ccp.c (debug_lattice_value): Likewise. * dominance.c (verify_dominators, debug_dominance_info, debug_dominance_tree): Likewise. * df-core.c (df_insn_uid_debug, df_insn_debug, df_insn_debug_regno, * df_regno_debug, df_ref_debug, debug_df_insn, debug_df_reg, debug_df_regno, debug_df_ref, debug_df_defno, debug_df_useno, debug_df_chain): Likewise. * tree-ssa-dom.c (debug_dominator_optimization_stats): Likewise. * sel-sched.c (debug_state): Likewise. * tree-ssa-alias.c (debug_alias_info, debug_points_to_info_for): Likewise. * cfganal.c (print_edge_list, verify_edge_list): Likewise. * dwarf2out.c (debug_dwarf_die, debug_dwarf): Likewise. * tree-eh.c (verify_eh_edges, verify_eh_dispatch_edge): Likewise. * gimple-pretty-print.c (debug_gimple_stmt, debug_gimple_seq): Likewise. * c-pretty-print.c (debug_c_tree): Likewise. * sel-sched-dump.c (debug_insn_rtx, debug_vinsn, debug_expr, debug_insn debug_av_set, debug_lv_set, debug_ilist, debug_blist, debug_insn_vector, debug_hard_reg_set, debug_mem_addr_value): Likewise. * ebitmap.c (debug_ebitmap): Likewise. * function.c (debug_find_var_in_block_tree): Likewise. * print-rtl.c (debug_rtx): Likewise. (debug_rtx_count): Likewise. (debug_rtx_list, debug_rtx_range, debug_rtx_find): Likewise. * stor-layout.c (debug_rli): Likewise. * ipa.c (debug_cgraph_node_set, debug_varpool_node_set): Likewise. * tree-data-ref.c (debug_data_references, debug_data_dependence_relations, debug_data_reference, debug_data_dependence_relation, debug_rdg_vertex, debug_rdg_component, debug_rdg): Likewise. * tree-affine.c (debug_aff): Likewise. * tree-dfa.c (debug_referenced_vars, debug_variable, debug_dfa_stats): Likewise. * except.c (debug_eh_tree, verify_eh_tree): Likewise. * emit-rtl.c (verify_rtl_sharing): Likewise. * tree-ssa-pre.c (debug_pre_expr, debug_bitmap_set, debug_value_expressions): Likewise. * tree-ssa-live.c (debug_scope_block, debug_scope_blocks): Likewise. * sese.c (debug_rename_map, debug_ivtype_map): Likewise. * print-tree.c (debug_tree, debug_vec_tree): Likewise. * cfglayout.c (verify_insn_chain): Likewise. * graphite-clast-to-gimple.c (debug_clast_name_indexes, debug_clast_stmt, debug_generated_program): Likewise. * ggc-page.c (debug_print_page_list): Likewise. * tree-ssa-ter.c (debug_ter): Likewise. * graphite-dependences.c (debug_pddr): Likewise. * sched-deps.c (debug_ds): Likewise. * tree-ssa.c (verify_ssa): Likewise. * graphite-poly.c (debug_scattering_function, debug_iteration_domain, debug_scattering_functions, debug_iteration_domains, debug_pdr, debug_pdrs, debug_pbb_domain, debug_pbb, debug_scop_context, debug_scop, debug_cloog, debug_scop_params, debug_lst): Likewise. * tree-inline.c (debug_find_tree): Likewise. * graphite-ppl.c (debug_ppl_linear_expr, debug_ppl_polyhedron_matrix, debug_ppl_powerset_matrix): Likewise. * var-tracking.c (debug_dv): Likewise. * system.h (DEBUG_FUNCTION, DEBUG_VARIABLE): Define. * cfgloop.c (verify_loop_structure): Likewise. * plugin.c (dump_active_plugins, debug_active_plugins): Likewise. * c-common.c (verify_sequence_points): Likewise. * sched-rgn.c (debug_regions, debug_region, debug_candidate, debug_candidates, debug_rgn_dependencies): Likewise. * tree-ssa-structalias.c (debug_constraint, debug_constraints, * debug_constraint_graph, debug_solution_for_var, debug_sa_points_to_info): Likewise. * sched-vis.c (debug_insn_slim, debug_bb_slim, debug_bb_n_slim): Likewie. * tree-cfg.c (debug_cfg_stats, verify_stmts, debug_function, debug_loops, debug_loop, debug_loop_num): Likewise. * passes.c (debug_pass): Likewise. (dump_properties): Likewise; add cfglayout property. (debug_properties): Likewise. * tree-ssa-reassoc.c (debug_ops_vector): Likewise. * varpool.c (debug_varpool): Likewise. * regcprop.c (debug_value_data): Likewise. * tree-ssa-operands.c (verify_imm_links, debug_immediate_uses, debug_immediate_uses_for): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160036 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a70c09fb3f5..e42e81c60a1 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4544,7 +4544,7 @@ debug_find_tree_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, void *data) return NULL; } -bool +DEBUG_FUNCTION bool debug_find_tree (tree top, tree search) { return walk_tree_without_duplicates (&top, debug_find_tree_1, search) != 0; -- cgit v1.2.1 From 39a98435d5b965a89ee773e57a73fe2b22cc4584 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 31 May 2010 15:38:35 +0000 Subject: PR tree-optimization/44182 * tree-inline.c (copy_edges_for_bb): Don't split bb if a stmt that newly needs to end a bb is followed by debug stmts, instead return true from the function at the end. (maybe_move_debug_stmts_to_successors): New function. (copy_cfg_body): Call it if copy_edges_for_bb returned true. * g++.dg/debug/pr44182.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160074 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 5 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e42e81c60a1..3055b5797fb 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1834,9 +1834,10 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb, /* Copy edges from BB into its copy constructed earlier, scale profile accordingly. Edges will be taken care of later. Assume aux - pointers to point to the copies of each BB. */ + pointers to point to the copies of each BB. Return true if any + debug stmts are left after a statement that must end the basic block. */ -static void +static bool copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) { basic_block new_bb = (basic_block) bb->aux; @@ -1844,6 +1845,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) edge old_edge; gimple_stmt_iterator si; int flags; + bool need_debug_cleanup = false; /* Use the indices from the original blocks to create edges for the new ones. */ @@ -1864,7 +1866,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) } if (bb->index == ENTRY_BLOCK || bb->index == EXIT_BLOCK) - return; + return false; for (si = gsi_start_bb (new_bb); !gsi_end_p (si);) { @@ -1898,6 +1900,13 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) if (can_throw || nonlocal_goto) { + if (!gsi_end_p (si)) + { + while (!gsi_end_p (si) && is_gimple_debug (gsi_stmt (si))) + gsi_next (&si); + if (gsi_end_p (si)) + need_debug_cleanup = true; + } if (!gsi_end_p (si)) /* Note that bb's predecessor edges aren't necessarily right at this point; split_block doesn't care. */ @@ -1923,6 +1932,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) update_ssa_across_abnormal_edges (gimple_bb (copy_stmt), ret_bb, can_throw, nonlocal_goto); } + return need_debug_cleanup; } /* Copy the PHIs. All blocks and edges are copied, some blocks @@ -2059,6 +2069,63 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count) pop_cfun (); } +/* Helper function for copy_cfg_body. Move debug stmts from the end + of NEW_BB to the beginning of successor basic blocks when needed. If the + successor has multiple predecessors, reset them, otherwise keep + their value. */ + +static void +maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb) +{ + edge e; + edge_iterator ei; + gimple_stmt_iterator si = gsi_last_nondebug_bb (new_bb); + + if (gsi_end_p (si) + || gsi_one_before_end_p (si) + || !(stmt_can_throw_internal (gsi_stmt (si)) + || stmt_can_make_abnormal_goto (gsi_stmt (si)))) + return; + + FOR_EACH_EDGE (e, ei, new_bb->succs) + { + gimple_stmt_iterator ssi = gsi_last_bb (new_bb); + gimple_stmt_iterator dsi = gsi_after_labels (e->dest); + while (is_gimple_debug (gsi_stmt (ssi))) + { + gimple stmt = gsi_stmt (ssi), new_stmt; + tree var; + tree value; + + /* For the last edge move the debug stmts instead of copying + them. */ + if (ei_one_before_end_p (ei)) + { + si = ssi; + gsi_prev (&ssi); + if (!single_pred_p (e->dest)) + gimple_debug_bind_reset_value (stmt); + gsi_remove (&si, false); + gsi_insert_before (&dsi, stmt, GSI_SAME_STMT); + continue; + } + + var = gimple_debug_bind_get_var (stmt); + if (single_pred_p (e->dest)) + { + value = gimple_debug_bind_get_value (stmt); + value = unshare_expr (value); + } + else + value = NULL_TREE; + new_stmt = gimple_build_debug_bind (var, value, stmt); + gsi_insert_before (&dsi, new_stmt, GSI_SAME_STMT); + VEC_safe_push (gimple, heap, id->debug_stmts, new_stmt); + gsi_prev (&ssi); + } + } +} + /* Make a copy of the body of FN so that it can be inserted inline in another function. Walks FN via CFG, returns new fndecl. */ @@ -2072,6 +2139,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, struct function *cfun_to_copy; basic_block bb; tree new_fndecl = NULL; + bool need_debug_cleanup = false; gcov_type count_scale; int last; @@ -2112,7 +2180,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, /* Now that we've duplicated the blocks, duplicate their edges. */ FOR_ALL_BB_FN (bb, cfun_to_copy) - copy_edges_for_bb (bb, count_scale, exit_block_map); + need_debug_cleanup |= copy_edges_for_bb (bb, count_scale, exit_block_map); if (gimple_in_ssa_p (cfun)) FOR_ALL_BB_FN (bb, cfun_to_copy) @@ -2120,6 +2188,10 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, FOR_ALL_BB_FN (bb, cfun_to_copy) { + if (need_debug_cleanup + && bb->index != ENTRY_BLOCK + && bb->index != EXIT_BLOCK) + maybe_move_debug_stmts_to_successors (id, (basic_block) bb->aux); ((basic_block)bb->aux)->aux = NULL; bb->aux = NULL; } @@ -2127,7 +2199,11 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, /* Zero out AUX fields of newly created block during EH edge insertion. */ for (; last < last_basic_block; last++) - BASIC_BLOCK (last)->aux = NULL; + { + if (need_debug_cleanup) + maybe_move_debug_stmts_to_successors (id, BASIC_BLOCK (last)); + BASIC_BLOCK (last)->aux = NULL; + } entry_block_map->aux = NULL; exit_block_map->aux = NULL; -- cgit v1.2.1 From 69862f316227d697044b7521e9ae44a2dabb7393 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 1 Jun 2010 09:36:21 +0000 Subject: * tree-inline.c (estimate_num_insns): For stdarg functions look into call statement to count cost of argument passing. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160094 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3055b5797fb..4ac1b3fb71d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3367,6 +3367,7 @@ estimate_num_insns (gimple stmt, eni_weights *weights) tree decl = gimple_call_fndecl (stmt); tree addr = gimple_call_fn (stmt); tree funtype = TREE_TYPE (addr); + bool stdarg = false; if (POINTER_TYPE_P (funtype)) funtype = TREE_TYPE (funtype); @@ -3475,17 +3476,26 @@ estimate_num_insns (gimple stmt, eni_weights *weights) if (!VOID_TYPE_P (TREE_TYPE (funtype))) cost += estimate_move_cost (TREE_TYPE (funtype)); + + if (funtype) + stdarg = stdarg_p (funtype); + /* Our cost must be kept in sync with cgraph_estimate_size_after_inlining that does use function - declaration to figure out the arguments. */ - if (decl && DECL_ARGUMENTS (decl)) + declaration to figure out the arguments. + + For functions taking variable list of arguments we must + look into call statement intself. This is safe because + we will get only higher costs and in most cases we will + not inline these anyway. */ + if (decl && DECL_ARGUMENTS (decl) && !stdarg) { tree arg; for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg)) if (!VOID_TYPE_P (TREE_TYPE (arg))) cost += estimate_move_cost (TREE_TYPE (arg)); } - else if (funtype && prototype_p (funtype)) + else if (funtype && prototype_p (funtype) && !stdarg) { tree t; for (t = TYPE_ARG_TYPES (funtype); t && t != void_list_node; -- cgit v1.2.1 From b06ab5fa20dbda4293d1ecf45ec0087f4ea4cd82 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 1 Jun 2010 15:43:27 +0000 Subject: * cgraph.h (tree_function_versioning): Update prototype. (cgraph_function_versioning): Update prototype. * cgraphunit.c (cgraph_copy_node_for_versioning): Accept bbs_to_copy bitmap. (cgraph_function_versioning): Accept new_entry_block and bbs_to_copy. (cgraph_materialize_clone, save_inline_function_body): Update use of tree_function_versioning. * tree-inline.c (copy_bb): Look for previous copied block to link after; fix debug output. (copy_cfg_body): Accept new_entry_block and bbs_to_copy. (copy_body): Likewise. (expand_call_inline): Update use of copy_body. (tree_function_versioning): Update use of copy body; accept blocks_to_copy and new_entry. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160110 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 76 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 23 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 4ac1b3fb71d..fce6ae54a6b 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1488,11 +1488,17 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, basic_block copy_basic_block; tree decl; gcov_type freq; + basic_block prev; + + /* Search for previous copied basic block. */ + prev = bb->prev_bb; + while (!prev->aux) + prev = prev->prev_bb; /* create_basic_block() will append every new block to basic_block_info automatically. */ copy_basic_block = create_basic_block (NULL, (void *) 0, - (basic_block) bb->prev_bb->aux); + (basic_block) prev->aux); copy_basic_block->count = bb->count * count_scale / REG_BR_PROB_BASE; /* We are going to rebuild frequencies from scratch. These values @@ -1728,7 +1734,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, = CIF_ORIGINALLY_INDIRECT_CALL; if (dump_file) { - fprintf (dump_file, "Created new direct edge to %s", + fprintf (dump_file, "Created new direct edge to %s\n", cgraph_node_name (dest)); } } @@ -2131,7 +2137,8 @@ maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb) static tree copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, - basic_block entry_block_map, basic_block exit_block_map) + basic_block entry_block_map, basic_block exit_block_map, + bitmap blocks_to_copy, basic_block new_entry) { tree callee_fndecl = id->src_fn; /* Original cfun for the callee, doesn't change. */ @@ -2170,32 +2177,46 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, /* Use aux pointers to map the original blocks to copy. */ FOR_EACH_BB_FN (bb, cfun_to_copy) - { - basic_block new_bb = copy_bb (id, bb, frequency_scale, count_scale); - bb->aux = new_bb; - new_bb->aux = bb; - } + if (!blocks_to_copy || bitmap_bit_p (blocks_to_copy, bb->index)) + { + basic_block new_bb = copy_bb (id, bb, frequency_scale, count_scale); + bb->aux = new_bb; + new_bb->aux = bb; + } last = last_basic_block; /* Now that we've duplicated the blocks, duplicate their edges. */ FOR_ALL_BB_FN (bb, cfun_to_copy) - need_debug_cleanup |= copy_edges_for_bb (bb, count_scale, exit_block_map); + if (!blocks_to_copy + || (bb->index > 0 && bitmap_bit_p (blocks_to_copy, bb->index))) + need_debug_cleanup |= copy_edges_for_bb (bb, count_scale, exit_block_map); if (gimple_in_ssa_p (cfun)) FOR_ALL_BB_FN (bb, cfun_to_copy) - copy_phis_for_bb (bb, id); + if (!blocks_to_copy + || (bb->index > 0 && bitmap_bit_p (blocks_to_copy, bb->index))) + copy_phis_for_bb (bb, id); - FOR_ALL_BB_FN (bb, cfun_to_copy) + if (new_entry) { - if (need_debug_cleanup - && bb->index != ENTRY_BLOCK - && bb->index != EXIT_BLOCK) - maybe_move_debug_stmts_to_successors (id, (basic_block) bb->aux); - ((basic_block)bb->aux)->aux = NULL; - bb->aux = NULL; + edge e; + e = make_edge (entry_block_map, (basic_block)new_entry->aux, EDGE_FALLTHRU); + e->probability = REG_BR_PROB_BASE; + e->count = entry_block_map->count; } + FOR_ALL_BB_FN (bb, cfun_to_copy) + if (bb->aux) + { + if (need_debug_cleanup + && bb->index != ENTRY_BLOCK + && bb->index != EXIT_BLOCK) + maybe_move_debug_stmts_to_successors (id, (basic_block) bb->aux); + ((basic_block)bb->aux)->aux = NULL; + bb->aux = NULL; + } + /* Zero out AUX fields of newly created block during EH edge insertion. */ for (; last < last_basic_block; last++) @@ -2317,14 +2338,16 @@ copy_tree_body (copy_body_data *id) static tree copy_body (copy_body_data *id, gcov_type count, int frequency_scale, - basic_block entry_block_map, basic_block exit_block_map) + basic_block entry_block_map, basic_block exit_block_map, + bitmap blocks_to_copy, basic_block new_entry) { tree fndecl = id->src_fn; tree body; /* If this body has a CFG, walk CFG and copy. */ gcc_assert (ENTRY_BLOCK_PTR_FOR_FUNCTION (DECL_STRUCT_FUNCTION (fndecl))); - body = copy_cfg_body (id, count, frequency_scale, entry_block_map, exit_block_map); + body = copy_cfg_body (id, count, frequency_scale, entry_block_map, exit_block_map, + blocks_to_copy, new_entry); copy_debug_stmts (id); return body; @@ -3924,7 +3947,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) duplicate our body before altering anything. */ copy_body (id, bb->count, cg_edge->frequency * REG_BR_PROB_BASE / CGRAPH_FREQ_BASE, - bb, return_block); + bb, return_block, NULL, NULL); /* Reset the escaped solution. */ if (cfun->gimple_df) @@ -4957,11 +4980,18 @@ update_clone_info (copy_body_data * id) tree with another tree while duplicating the function's body, TREE_MAP represents the mapping between these trees. If UPDATE_CLONES is set, the call_stmt fields - of edges of clones of the function will be updated. */ + of edges of clones of the function will be updated. + + If non-NULL ARGS_TO_SKIP determine function parameters to remove + from new version. + If non-NULL BLOCK_TO_COPY determine what basic blocks to copy. + If non_NULL NEW_ENTRY determine new entry BB of the clone. +*/ void tree_function_versioning (tree old_decl, tree new_decl, VEC(ipa_replace_map_p,gc)* tree_map, - bool update_clones, bitmap args_to_skip) + bool update_clones, bitmap args_to_skip, + bitmap blocks_to_copy, basic_block new_entry) { struct cgraph_node *old_version_node; struct cgraph_node *new_version_node; @@ -5113,7 +5143,7 @@ tree_function_versioning (tree old_decl, tree new_decl, /* Copy the Function's body. */ copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE, - ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR); + ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, blocks_to_copy, new_entry); if (DECL_RESULT (old_decl) != NULL_TREE) { -- cgit v1.2.1 From 8e3cb73bc66100e137b20bcd98316bc415b6e53c Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 1 Jun 2010 22:00:56 +0000 Subject: * gimplify.c: Do not include except.h and optabs.h. (gimplify_body): Do not initialize RTL profiling. * gimple-low.c: Do not include rtl.h, diagnostic.h, langhooks.h, langhooks-def.h, timevar.h, except.h, hashtab.h, and expr.h. * gimple-fold.c: Do not include rtl.h, tm_p.h, ggc.h, basic-block.h, output.h, expr.h, diagnostic.h, timevar.h, value-prof.h, and langhooks.h. * tree-pretty-print.h: Include pretty-print.h. * gimple-pretty-print.h: Include pretty-print.h. * tree-pretty-print.c: Do not include diagnostic.h. * tree-vrp.c: Likewise. * tree-tailcall.c: Likewise * tree-scalar-evolution.c: Likewise * tree-ssa-dse.c: Likewise * tree-chrec.c: Likewise * tree-ssa-sccvn.c: Likewise * tree-ssa-copyrename.c: Likewise * tree-nomudflap.c: Likewise * tree-call-cdce.c: Likewise * tree-stdarg.c: Likewise * tree-ssa-math-opts.c: Likewise * tree-nrv.c: Likewise * tree-ssa-sink.c: Likewise * tree-browser.c: Likewise * tree-ssa-loop-ivcanon.c: Likewise * tree-ssa-loop.c: Likewise * tree-parloops.c: Likewise * tree-ssa-address.c: Likewise * tree-ssa-ifcombine.c: Likewise * tree-if-conv.c: Likewise * tree-data-ref.c: Likewise * tree-affine.c: Likewise * tree-ssa-phiopt.c: Likewise * tree-ssa-coalesce.c: Likewise * tree-ssa-pre.c: Likewise * tree-ssa-live.c: Likewise * tree-predcom.c: Likewise * tree-ssa-forwprop.c: Likewise * tree-ssa-dce.c: Likewise * tree-ssa-ter.c: Likewise * tree-ssa-loop-prefetch.c: Likewise * tree-optimize.c: Likewise * tree-ssa-phiprop.c: Likewise * tree-object-size.c: Likewise * tree-outof-ssa.c: Likewise * tree-ssa-structalias.c: Likewise * tree-switch-conversion.c: Likewise * tree-ssa-reassoc.c: Likewise * tree-ssa-operands.c: Likewise * tree-vectorizer.c: Likewise * tree-vect-data-refs.c: Likewise * tree-vect-generic.c: Likewise * tree-vect-stmts.c: Likewise * tree-vect-patterns.c: Likewise * tree-vect-slp.c: Likewise * tree-vect-loop.c: Likewise * tree-ssa-loop-ivopts.c: Likewise * tree-ssa-loop-im.c: Likewise * tree-ssa-loop-niter.c: Likewise * tree-ssa-loop-unswitch.c: Likewise * tree-ssa-loop-manip.c: Likewise * tree-ssa-loop-ch.c: Likewise * tree-dump.c: Likewise * tree-complex.c: Likewise * tree-into-ssa.c: Do not include diagnostic.h and expr.h. * tree-ssa-uninit.c: Likewise * tree-ssa-threadupdate.c: Likewise * tree-ssa-uncprop.c: Likewise * tree-ssa-ccp.c: Likewise * tree-ssa-dom.c: Likewise * tree-ssa-propagate.c: Likewise * tree-ssa-alias.c: Likewise * tree-dfa.c: Likewise * tree-cfgcleanup.c: Likewise * tree-sra.c: Likewise * tree-ssa-copy.c: Likewise * tree-ssa.c: Likewise * tree-profile.c: Likewise * tree-cfg.c: Likewise * tree-ssa-threadedge.c: Likewise * tree-vect-loop-manip.c: Likewise * tree-inline.c: Do not include diagnostic.h and expr.h. Include rtl.h. (copy_decl_for_dup_finish): Do not use NULL_RTX. * tree-loop-linear.c: Do not include diagnostic.h, expr.h, and optabs.h. * tree-loop-distribution.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160125 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index fce6ae54a6b..696cb00fbfd 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -26,7 +26,6 @@ along with GCC; see the file COPYING3. If not see #include "toplev.h" #include "tree.h" #include "tree-inline.h" -#include "expr.h" #include "flags.h" #include "params.h" #include "input.h" @@ -41,7 +40,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-flow.h" #include "function.h" #include "tree-flow.h" -#include "diagnostic.h" #include "tree-pretty-print.h" #include "except.h" #include "debug.h" @@ -52,6 +50,8 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "integrate.h" +#include "rtl.h" /* FIXME: For asm_str_count. */ + /* I'm not real happy about this, but we need to handle gimple and non-gimple trees. */ #include "gimple.h" @@ -4697,7 +4697,7 @@ copy_decl_for_dup_finish (copy_body_data *id, tree decl, tree copy) /* The new variable/label has no RTL, yet. */ if (CODE_CONTAINS_STRUCT (TREE_CODE (copy), TS_DECL_WRTL) && !TREE_STATIC (copy) && !DECL_EXTERNAL (copy)) - SET_DECL_RTL (copy, NULL_RTX); + SET_DECL_RTL (copy, 0); /* These args would always appear unused, if not for this. */ TREE_USED (copy) = 1; -- cgit v1.2.1 From 836045d7d14b773d7c2dcca5386c1a350766d173 Mon Sep 17 00:00:00 2001 From: pzhao Date: Tue, 8 Jun 2010 04:07:55 +0000 Subject: 2010-06-08 Shujing Zhao * fold-const.c (fold_comparison): Remove redundant parenthesis. * tree-inline.c (expand_call_inline): Pass translated return value of cgraph_inline_failed_string to diagnostic function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160419 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 696cb00fbfd..72bef2189da 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3774,7 +3774,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) && cgraph_global_info_ready) { sorry ("inlining failed in call to %q+F: %s", fn, - cgraph_inline_failed_string (reason)); + _(cgraph_inline_failed_string (reason))); sorry ("called from here"); } else if (warn_inline && DECL_DECLARED_INLINE_P (fn) @@ -3785,7 +3785,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) && cgraph_global_info_ready) { warning (OPT_Winline, "inlining failed in call to %q+F: %s", - fn, cgraph_inline_failed_string (reason)); + fn, _(cgraph_inline_failed_string (reason))); warning (OPT_Winline, "called from here"); } goto egress; -- cgit v1.2.1 From d603fd8614a143dec3d639929c643c3a58997717 Mon Sep 17 00:00:00 2001 From: rguenth Date: Wed, 16 Jun 2010 20:28:24 +0000 Subject: 2010-06-16 Richard Guenther * tree-inline.c (remap_gimple_op_r): Recurse using remap_gimple_op_r. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160860 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 72bef2189da..2ee34c87c60 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -892,7 +892,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) int invariant = is_gimple_min_invariant (*tp); tree block = id->block; id->block = NULL_TREE; - walk_tree (&TREE_OPERAND (*tp, 0), copy_tree_body_r, id, NULL); + walk_tree (&TREE_OPERAND (*tp, 0), remap_gimple_op_r, data, NULL); id->block = block; /* Handle the case where we substituted an INDIRECT_REF -- cgit v1.2.1 From df0c9c1a9edfae572198616adc60aa18779e6d54 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 17 Jun 2010 13:10:45 +0000 Subject: 2010-06-17 Richard Guenther * tree-inline.c (declare_return_variable): Remove bogus code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160910 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 2ee34c87c60..b241a21c348 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2701,25 +2701,6 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) via return slot optimization are not believed to have address taken by alias analysis. */ gcc_assert (TREE_CODE (return_slot) != SSA_NAME); - if (gimple_in_ssa_p (cfun)) - { - HOST_WIDE_INT bitsize; - HOST_WIDE_INT bitpos; - tree offset; - enum machine_mode mode; - int unsignedp; - int volatilep; - tree base; - base = get_inner_reference (return_slot, &bitsize, &bitpos, - &offset, - &mode, &unsignedp, &volatilep, - false); - if (TREE_CODE (base) == INDIRECT_REF) - base = TREE_OPERAND (base, 0); - if (TREE_CODE (base) == SSA_NAME) - base = SSA_NAME_VAR (base); - mark_sym_for_renaming (base); - } var = return_slot_addr; } else -- cgit v1.2.1 From 91aba934ea56cc649baee2ead192464a43d32cfc Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Tue, 22 Jun 2010 18:21:25 +0000 Subject: * cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee): Chain the new statement and adjust VDEF only if necessary. Remove superfluous call to maybe_clean_or_replace_eh_stmt. * gimple.c (gimple_call_copy_skip_args): Use gimple_call_copy_flags to copy the flags. * gimple-iterator.c (gsi_replace): Clear BB of old statement here... * tree-inline.c (copy_bb): ...and not there. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161221 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b241a21c348..0b6a7d2e2ee 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1604,7 +1604,6 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, gimple_call_set_lhs (new_call, gimple_call_lhs (stmt)); gsi_replace (©_gsi, new_call, false); - gimple_set_bb (stmt, NULL); stmt = new_call; } else if (is_gimple_call (stmt) -- cgit v1.2.1 From 00f4f70565fa903b89c2f1be5059898ddb069db0 Mon Sep 17 00:00:00 2001 From: bernds Date: Fri, 25 Jun 2010 08:56:24 +0000 Subject: With large parts from Jim Wilson: PR target/43902 * tree-pretty-print.c (dump_generic_node, op_code_prio): Add WIDEN_MULT_PLUS_EXPR and WIDEN_MULT_MINUS_EXPR. * optabs.c (optab_for_tree_code): Likewise. (expand_widen_pattern_expr): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): New function, broken out of execute_optimize_widening_mul. (convert_plusminus_to_widen): New function. (execute_optimize_widening_mul): Use the two new functions. * expr.c (expand_expr_real_2): Add support for GIMPLE_TERNARY_RHS. Remove code to generate widening multiply-accumulate. Add support for WIDEN_MULT_PLUS_EXPR and WIDEN_MULT_MINUS_EXPR. * gimple-pretty-print.c (dump_ternary_rhs): New function. (dump_gimple_assign): Call it when appropriate. * tree.def (WIDEN_MULT_PLUS_EXPR, WIDEN_MULT_MINUS_EXPR): New codes. * cfgexpand.c (gimple_assign_rhs_to_tree): Likewise. (expand_gimple_stmt_1): Likewise. (expand_debug_expr): Support WIDEN_MULT_PLUS_EXPR and WIDEN_MULT_MINUS_EXPR. * tree-ssa-operands.c (get_expr_operands): Likewise. * tree-inline.c (estimate_operator_cost): Likewise. * gimple.c (extract_ops_from_tree_1): Renamed from extract_ops_from_tree. Add new arg for a third operand; fill it. (gimple_build_assign_stat): Support operations with three operands. (gimple_build_assign_with_ops_stat): Likewise. (gimple_assign_set_rhs_from_tree): Likewise. (gimple_assign_set_rhs_with_ops_1): Renamed from gimple_assign_set_rhs_with_ops. Add new arg for a third operand. (get_gimple_rhs_num_ops): Support GIMPLE_TERNARY_RHS. (get_gimple_rhs_num_ops): Handle WIDEN_MULT_PLUS_EXPR and WIDEN_MULT_MINUS_EXPR. * gimple.h (enum gimple_rhs_class): Add GIMPLE_TERNARY_RHS. (extract_ops_from_tree_1): Adjust declaration. (gimple_assign_set_rhs_with_ops_1): Likewise. (gimple_build_assign_with_ops): Pass NULL for last operand. (gimple_build_assign_with_ops3): New macro. (gimple_assign_rhs3, gimple_assign_rhs3_ptr, gimple_assign_set_rhs3, gimple_assign_set_rhs_with_ops, extract_ops_from_tree): New inline functions. * tree-cfg.c (verify_gimple_assign_ternary): New static function. (verify_gimple_assign): Call it. * doc/gimple.texi (Manipulating operands): Document GIMPLE_TERNARY_RHS. (Tuple specific accessors, subsection GIMPLE_ASSIGN): Document new functions for dealing with three-operand statements. * tree.c (commutative_ternary_tree_code): New function. * tree.h (commutative_ternary_tree_code): Declare it. * tree-vrp.c (gimple_assign_nonnegative_warnv_p): Return false for ternary statements. (gimple_assign_nonzero_warnv_p): Likewise. * tree-ssa-sccvn.c (stmt_has_constants): Handle GIMPLE_TERNARY_RHS. * tree-ssa-ccp.c (get_rhs_assign_op_for_ccp): New static function. (ccp_fold): Use it. Handle GIMPLE_TERNARY_RHS. * tree-ssa-dom.c (enum expr_kind): Add EXPR_TERNARY. (struct hashtable_expr): New member ternary in the union. (initialize_hash_element): Handle GIMPLE_TERNARY_RHS. (hashable_expr_equal_p): Fix indentation. Handle EXPR_TERNARY. (iterative_hash_hashable_expr): Likewise. (print_expr_hash_elt): Handle EXPR_TERNARY. * gimple-fold.c (fold_gimple_assign): Handle GIMPLE_TERNARY_RHS. * tree-ssa-threadedge.c (fold_assignment_stmt): Remove useless break statements. Handle GIMPLE_TERNARY_RHS. testsuite/ PR target/43902 * gcc.target/mips/madd-9.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161366 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 0b6a7d2e2ee..bbbaa40d15e 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3238,6 +3238,8 @@ estimate_operator_cost (enum tree_code code, eni_weights *weights, case WIDEN_SUM_EXPR: case WIDEN_MULT_EXPR: case DOT_PROD_EXPR: + case WIDEN_MULT_PLUS_EXPR: + case WIDEN_MULT_MINUS_EXPR: case VEC_WIDEN_MULT_HI_EXPR: case VEC_WIDEN_MULT_LO_EXPR: -- cgit v1.2.1 From 81943faa41ebf431930486cfef403394f82ed48a Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 25 Jun 2010 13:09:28 +0000 Subject: =?UTF-8?q?2010-06-25=20=20Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez=20?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR 44665 * tree-inline.c (gimple_expand_calls_inline): Fix typo in comment. * gimplify.c (is_gimple_reg_rhs_or_call): Likewise. (gimplify_expr): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161380 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index bbbaa40d15e..f446fa7c55c 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4022,7 +4022,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) /* Expand call statements reachable from STMT_P. We can only have CALL_EXPRs as the "toplevel" tree code or nested - in a MODIFY_EXPR. See tree-gimple.c:get_call_expr_in(). We can + in a MODIFY_EXPR. See gimple.c:get_call_expr_in(). We can unfortunately not use that function here because we need a pointer to the CALL_EXPR, not the tree itself. */ -- cgit v1.2.1 From 6a69e8136b054143685286d32b04d4b765a57b26 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sat, 26 Jun 2010 14:45:40 +0000 Subject: * gcc.dg/tree-ssa/ipa-split-2.c: New testcase. * ipa-split.c (consider_split): PHI in entry block is OK as long as all edges comming from header are equivalent. (visit_bb): Handle PHIs correctly. * tree-inline.c (copy_phis_for_bb): Be able to copy PHI from entry edge. (copy_cfg_body): Produce edge from entry BB before copying PHIs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161433 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f446fa7c55c..a419c2612bf 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1969,11 +1969,22 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id) = new_phi = create_phi_node (new_res, new_bb); FOR_EACH_EDGE (new_edge, ei, new_bb->preds) { - edge const old_edge - = find_edge ((basic_block) new_edge->src->aux, bb); - tree arg = PHI_ARG_DEF_FROM_EDGE (phi, old_edge); - tree new_arg = arg; + edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb); + tree arg; + tree new_arg; tree block = id->block; + edge_iterator ei2; + + /* When doing partial clonning, we allow PHIs on the entry block + as long as all the arguments are the same. Find any input + edge to see argument to copy. */ + if (!old_edge) + FOR_EACH_EDGE (old_edge, ei2, bb->preds) + if (!old_edge->src->aux) + break; + + arg = PHI_ARG_DEF_FROM_EDGE (phi, old_edge); + new_arg = arg; id->block = NULL_TREE; walk_tree (&new_arg, copy_tree_body_r, id, NULL); id->block = block; @@ -2191,12 +2202,6 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, || (bb->index > 0 && bitmap_bit_p (blocks_to_copy, bb->index))) need_debug_cleanup |= copy_edges_for_bb (bb, count_scale, exit_block_map); - if (gimple_in_ssa_p (cfun)) - FOR_ALL_BB_FN (bb, cfun_to_copy) - if (!blocks_to_copy - || (bb->index > 0 && bitmap_bit_p (blocks_to_copy, bb->index))) - copy_phis_for_bb (bb, id); - if (new_entry) { edge e; @@ -2205,6 +2210,12 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, e->count = entry_block_map->count; } + if (gimple_in_ssa_p (cfun)) + FOR_ALL_BB_FN (bb, cfun_to_copy) + if (!blocks_to_copy + || (bb->index > 0 && bitmap_bit_p (blocks_to_copy, bb->index))) + copy_phis_for_bb (bb, id); + FOR_ALL_BB_FN (bb, cfun_to_copy) if (bb->aux) { -- cgit v1.2.1 From 2f25e4ca07e6763cd89b62f7c54e6c962580c9f0 Mon Sep 17 00:00:00 2001 From: rguenth Date: Tue, 29 Jun 2010 12:12:10 +0000 Subject: 2010-06-29 Richard Guenther PR middle-end/44667 * tree-inline.c (initialize_inlined_parameters): Make sure to remap the inlined parameter variable substitutions types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161527 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a419c2612bf..2604c6b1127 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2642,6 +2642,32 @@ initialize_inlined_parameters (copy_body_data *id, gimple stmt, val = i < gimple_call_num_args (stmt) ? gimple_call_arg (stmt, i) : NULL; setup_one_parameter (id, p, val, fn, bb, &vars); } + /* After remapping parameters remap their types. This has to be done + in a second loop over all parameters to appropriately remap + variable sized arrays when the size is specified in a + parameter following the array. */ + for (p = parms, i = 0; p; p = TREE_CHAIN (p), i++) + { + tree *varp = (tree *) pointer_map_contains (id->decl_map, p); + if (varp + && TREE_CODE (*varp) == VAR_DECL) + { + tree def = (gimple_in_ssa_p (cfun) + ? gimple_default_def (id->src_cfun, p) : NULL); + TREE_TYPE (*varp) = remap_type (TREE_TYPE (*varp), id); + /* Also remap the default definition if it was remapped + to the default definition of the parameter replacement + by the parameter setup. */ + if (def && gimple_in_ssa_p (cfun) && is_gimple_reg (p)) + { + tree *defp = (tree *) pointer_map_contains (id->decl_map, def); + if (defp + && TREE_CODE (*defp) == SSA_NAME + && SSA_NAME_VAR (*defp) == *varp) + TREE_TYPE (*defp) = TREE_TYPE (*varp); + } + } + } /* Initialize the static chain. */ p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl; -- cgit v1.2.1 From 555e8b05fce3ebfad73e482925e3fc55e8d2ae74 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 29 Jun 2010 14:14:15 +0000 Subject: * predict.c (propagate_freq): Clear EXIT_BLOCK_PTR frequency if it is unreachable. (rebuild_frequencies): New function. * predict.h (rebuild_frequencies): Declare. * tree-inline.c (copy_cfg_body): Compute properly count & frequency of entry block and edge reaching new_entry. (tree_function_versioning): When doing partial cloning, rebuild frequencies when done. * passes.c (execute_function_todo): Use rebild_frequencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161536 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 2604c6b1127..3ef1cc3832e 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2159,6 +2159,8 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, bool need_debug_cleanup = false; gcov_type count_scale; int last; + int incomming_frequency = 0; + gcov_type incomming_count = 0; if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count) count_scale = (REG_BR_PROB_BASE * count @@ -2169,6 +2171,28 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, /* Register specific tree functions. */ gimple_register_cfg_hooks (); + /* If we are inlining just region of the function, make sure to connect new entry + to ENTRY_BLOCK_PTR. Since new entry can be part of loop, we must compute + frequency and probability of ENTRY_BLOCK_PTR based on the frequencies and + probabilities of edges incomming from nonduplicated region. */ + if (new_entry) + { + edge e; + edge_iterator ei; + + FOR_EACH_EDGE (e, ei, new_entry->preds) + if (!e->src->aux) + { + incomming_frequency += EDGE_FREQUENCY (e); + incomming_count += e->count; + } + incomming_count = incomming_count * count_scale / REG_BR_PROB_BASE; + incomming_frequency + = incomming_frequency * frequency_scale / REG_BR_PROB_BASE; + ENTRY_BLOCK_PTR->count = incomming_count; + ENTRY_BLOCK_PTR->frequency = incomming_frequency; + } + /* Must have a CFG here at this point. */ gcc_assert (ENTRY_BLOCK_PTR_FOR_FUNCTION (DECL_STRUCT_FUNCTION (callee_fndecl))); @@ -2204,10 +2228,9 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, if (new_entry) { - edge e; - e = make_edge (entry_block_map, (basic_block)new_entry->aux, EDGE_FALLTHRU); + edge e = make_edge (entry_block_map, (basic_block)new_entry->aux, EDGE_FALLTHRU); e->probability = REG_BR_PROB_BASE; - e->count = entry_block_map->count; + e->count = incomming_count; } if (gimple_in_ssa_p (cfun)) @@ -5206,6 +5229,23 @@ tree_function_versioning (tree old_decl, tree new_decl, if (id.dst_node->analyzed) cgraph_rebuild_references (); update_ssa (TODO_update_ssa); + + /* After partial cloning we need to rescale frequencies, so they are + within proper range in the cloned function. */ + if (new_entry) + { + struct cgraph_edge *e; + rebuild_frequencies (); + + new_version_node->count = ENTRY_BLOCK_PTR->count; + for (e = new_version_node->callees; e; e = e->next_callee) + { + basic_block bb = gimple_bb (e->call_stmt); + e->frequency = compute_call_stmt_bb_frequency (current_function_decl, bb); + e->count = bb->count; + } + } + free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); -- cgit v1.2.1 From 292233cd15a6655be048141a27ac4bf1e3a46c73 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 29 Jun 2010 14:26:00 +0000 Subject: * tree-inline.c: Replace incomming by incomin and clonning by cloning. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161537 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3ef1cc3832e..3aa5f7c5baa 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1712,7 +1712,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, /* We have missing edge in the callgraph. This can happen when previous inlining turned an indirect call into a direct call by constant propagating arguments or we are - producing dead clone (for further clonning). In all + producing dead clone (for further cloning). In all other cases we hit a bug (incorrect node sharing is the most common reason for missing edges). */ gcc_assert (dest->needed || !dest->analyzed @@ -1975,7 +1975,7 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id) tree block = id->block; edge_iterator ei2; - /* When doing partial clonning, we allow PHIs on the entry block + /* When doing partial cloning, we allow PHIs on the entry block as long as all the arguments are the same. Find any input edge to see argument to copy. */ if (!old_edge) @@ -2042,7 +2042,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count) gcc_assert (cfun->cfg == NULL); gcc_assert (cfun->decl == new_fndecl); - /* Copy items we preserve during clonning. */ + /* Copy items we preserve during cloning. */ cfun->static_chain_decl = src_cfun->static_chain_decl; cfun->nonlocal_goto_save_area = src_cfun->nonlocal_goto_save_area; cfun->function_end_locus = src_cfun->function_end_locus; @@ -2159,8 +2159,8 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, bool need_debug_cleanup = false; gcov_type count_scale; int last; - int incomming_frequency = 0; - gcov_type incomming_count = 0; + int incoming_frequency = 0; + gcov_type incoming_count = 0; if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count) count_scale = (REG_BR_PROB_BASE * count @@ -2174,7 +2174,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, /* If we are inlining just region of the function, make sure to connect new entry to ENTRY_BLOCK_PTR. Since new entry can be part of loop, we must compute frequency and probability of ENTRY_BLOCK_PTR based on the frequencies and - probabilities of edges incomming from nonduplicated region. */ + probabilities of edges incoming from nonduplicated region. */ if (new_entry) { edge e; @@ -2183,14 +2183,14 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, FOR_EACH_EDGE (e, ei, new_entry->preds) if (!e->src->aux) { - incomming_frequency += EDGE_FREQUENCY (e); - incomming_count += e->count; + incoming_frequency += EDGE_FREQUENCY (e); + incoming_count += e->count; } - incomming_count = incomming_count * count_scale / REG_BR_PROB_BASE; - incomming_frequency - = incomming_frequency * frequency_scale / REG_BR_PROB_BASE; - ENTRY_BLOCK_PTR->count = incomming_count; - ENTRY_BLOCK_PTR->frequency = incomming_frequency; + incoming_count = incoming_count * count_scale / REG_BR_PROB_BASE; + incoming_frequency + = incoming_frequency * frequency_scale / REG_BR_PROB_BASE; + ENTRY_BLOCK_PTR->count = incoming_count; + ENTRY_BLOCK_PTR->frequency = incoming_frequency; } /* Must have a CFG here at this point. */ @@ -2230,7 +2230,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, { edge e = make_edge (entry_block_map, (basic_block)new_entry->aux, EDGE_FALLTHRU); e->probability = REG_BR_PROB_BASE; - e->count = incomming_count; + e->count = incoming_count; } if (gimple_in_ssa_p (cfun)) -- cgit v1.2.1 From 2e6614510ab3fb9b079986ea25e4b04363dcc7d0 Mon Sep 17 00:00:00 2001 From: bernds Date: Wed, 30 Jun 2010 14:16:28 +0000 Subject: PR tree-optimization/39799 * tree-inline.c (remap_ssa_name): Initialize variable only if SSA_NAME_OCCURS_IN_ABNORMAL_PHI. testsuite/ PR tree-optimization/39799 * c-c++-common/uninit-17.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161605 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3aa5f7c5baa..f1470d7a384 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -234,6 +234,7 @@ remap_ssa_name (tree name, copy_body_data *id) regions of the CFG, but this is expensive to test. */ if (id->entry_bb && is_gimple_reg (SSA_NAME_VAR (name)) + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name) && TREE_CODE (SSA_NAME_VAR (name)) != PARM_DECL && (id->entry_bb != EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest || EDGE_COUNT (id->entry_bb->preds) != 1)) -- cgit v1.2.1 From 182cf5a9a415f31df0f9a10e46faed1221484a35 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 1 Jul 2010 08:49:19 +0000 Subject: 2010-07-01 Richard Guenther PR middle-end/42834 PR middle-end/44468 * doc/gimple.texi (is_gimple_mem_ref_addr): Document. * doc/generic.texi (References to storage): Document MEM_REF. * tree-pretty-print.c (dump_generic_node): Handle MEM_REF. (print_call_name): Likewise. * tree.c (recompute_tree_invariant_for_addr_expr): Handle MEM_REF. (build_simple_mem_ref_loc): New function. (mem_ref_offset): Likewise. * tree.h (build_simple_mem_ref_loc): Declare. (build_simple_mem_ref): Define. (mem_ref_offset): Declare. * fold-const.c: Include tree-flow.h. (operand_equal_p): Handle MEM_REF. (build_fold_addr_expr_with_type_loc): Likewise. (fold_comparison): Likewise. (fold_unary_loc): Fold VIEW_CONVERT_EXPR > to MEM_REF . (fold_binary_loc): Fold MEM[&MEM[p, CST1], CST2] to MEM[p, CST1 + CST2], fold MEM[&a.b, CST2] to MEM[&a, offsetof (a, b) + CST2]. * tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Handle MEM_REF. (ptr_deref_may_alias_ref_p_1): Likewise. (ao_ref_base_alias_set): Properly differentiate base object for offset and TBAA. (ao_ref_init_from_ptr_and_size): Use MEM_REF. (indirect_ref_may_alias_decl_p): Handle MEM_REFs properly. (indirect_refs_may_alias_p): Likewise. (refs_may_alias_p_1): Likewise. Remove pointer SSA name def chasing code. (ref_maybe_used_by_call_p_1): Handle MEM_REF. (call_may_clobber_ref_p_1): Likewise. * dwarf2out.c (loc_list_from_tree): Handle MEM_REF. * expr.c (expand_assignment): Handle MEM_REF. (store_expr): Handle MEM_REFs from STRING_CSTs. (store_field): If expanding a MEM_REF of a non-addressable decl use bitfield operations. (get_inner_reference): Handle MEM_REF. (expand_expr_addr_expr_1): Likewise. (expand_expr_real_1): Likewise. * tree-eh.c (tree_could_trap_p): Handle MEM_REF. * alias.c (ao_ref_from_mem): Handle MEM_REF. (get_alias_set): Likewise. Properly handle VIEW_CONVERT_EXPRs. * tree-data-ref.c (dr_analyze_innermost): Handle MEM_REF. (dr_analyze_indices): Likewise. (dr_analyze_alias): Likewise. (object_address_invariant_in_loop_p): Likewise. * gimplify.c (mark_addressable): Handle MEM_REF. (gimplify_cond_expr): Build MEM_REFs. (gimplify_modify_expr_to_memcpy): Likewise. (gimplify_init_ctor_preeval_1): Handle MEM_REF. (gimple_fold_indirect_ref): Adjust. (gimplify_expr): Handle MEM_REF. Gimplify INDIRECT_REF to MEM_REF. * tree.def (MEM_REF): New tree code. * tree-dfa.c: Include toplev.h. (get_ref_base_and_extent): Handle MEM_REF. (get_addr_base_and_unit_offset): New function. * emit-rtl.c (set_mem_attributes_minus_bitpos): Handle MEM_REF. * gimple-fold.c (may_propagate_address_into_dereference): Handle MEM_REF. (maybe_fold_offset_to_array_ref): Allow possibly out-of bounds accesses if the array has just one dimension. Remove always true parameter. Do not require type compatibility here. (maybe_fold_offset_to_component_ref): Remove. (maybe_fold_stmt_indirect): Remove. (maybe_fold_reference): Remove INDIRECT_REF handling. Fold back to non-MEM_REF. (maybe_fold_offset_to_address): Simplify. Deal with type mismatches here. (maybe_fold_reference): Likewise. (maybe_fold_stmt_addition): Likewise. Also handle &ARRAY + I in addition to &ARRAY[0] + I. (fold_gimple_assign): Handle ADDR_EXPR of MEM_REFs. (gimple_get_relevant_ref_binfo): Handle MEM_REF. * cfgexpand.c (expand_debug_expr): Handle MEM_REF. * tree-ssa.c (useless_type_conversion_p): Make most pointer conversions useless. (warn_uninitialized_var): Handle MEM_REF. (maybe_rewrite_mem_ref_base): New function. (execute_update_addresses_taken): Implement re-writing of MEM_REFs to SSA form. * tree-inline.c (remap_gimple_op_r): Handle MEM_REF, remove INDIRECT_REF handling. (copy_tree_body_r): Handle MEM_REF. * gimple.c (is_gimple_addressable): Adjust. (is_gimple_address): Likewise. (is_gimple_invariant_address): ADDR_EXPRs of MEM_REFs with invariant base are invariant. (is_gimple_min_lval): Adjust. (is_gimple_mem_ref_addr): New function. (get_base_address): Handle MEM_REF. (count_ptr_derefs): Likewise. (get_base_loadstore): Likewise. * gimple.h (is_gimple_mem_ref_addr): Declare. (gimple_call_fndecl): Handle invariant MEM_REF addresses. * tree-cfg.c (verify_address): New function, split out from ... (verify_expr): ... here. Use for verifying ADDR_EXPRs and the address operand of MEM_REFs. Verify MEM_REFs. Reject INDIRECT_REFs. (verify_types_in_gimple_min_lval): Handle MEM_REF. Disallow INDIRECT_REF. Allow conversions. (verify_types_in_gimple_reference): Verify VIEW_CONVERT_EXPR of a register does not change its size. (verify_types_in_gimple_reference): Verify MEM_REF. (verify_gimple_assign_single): Disallow INDIRECT_REF. Handle MEM_REF. * tree-ssa-operands.c (opf_non_addressable, opf_not_non_addressable): New. (mark_address_taken): Handle MEM_REF. (get_indirect_ref_operands): Pass through opf_not_non_addressable. (get_asm_expr_operands): Pass opf_not_non_addressable. (get_expr_operands): Handle opf_[not_]non_addressable. Handle MEM_REF. Remove INDIRECT_REF handling. * tree-vrp.c: (check_array_ref): Handle MEM_REF. (search_for_addr_array): Likewise. (check_array_bounds): Likewise. (vrp_stmt_computes_nonzero): Adjust for MEM_REF. * tree-ssa-loop-im.c (for_each_index): Handle MEM_REF. (ref_always_accessed_p): Likewise. (gen_lsm_tmp_name): Likewise. Handle ADDR_EXPR. * tree-complex.c (extract_component): Do not handle INDIRECT_REF. Handle MEM_REF. * cgraphbuild.c (mark_load): Properly check for NULL result from get_base_address. (mark_store): Likewise. * tree-ssa-loop-niter.c (array_at_struct_end_p): Handle MEM_REF. * tree-loop-distribution.c (generate_builtin): Exchange INDIRECT_REF handling for MEM_REF. * tree-scalar-evolution.c (follow_ssa_edge_expr): Handle &MEM[ptr + CST] similar to POINTER_PLUS_EXPR. * builtins.c (stabilize_va_list_loc): Use the function ABI valist type if we couldn't canonicalize the argument type. Always dereference with the canonical va-list type. (maybe_emit_free_warning): Handle MEM_REF. (fold_builtin_memory_op): Simplify and handle MEM_REFs in folding memmove to memcpy. * builtins.c (fold_builtin_memory_op): Use ref-all types for all memcpy foldings. * omp-low.c (build_receiver_ref): Adjust for MEM_REF. (build_outer_var_ref): Likewise. (scan_omp_1_op): Likewise. (lower_rec_input_clauses): Likewise. (lower_lastprivate_clauses): Likewise. (lower_reduction_clauses): Likewise. (lower_copyprivate_clauses): Likewise. (expand_omp_atomic_pipeline): Likewise. (expand_omp_atomic_mutex): Likewise. (create_task_copyfn): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle MEM_REF. Remove old union trick. Initialize constant offsets. (ao_ref_init_from_vn_reference): Likewise. Do not handle INDIRECT_REF. Init base_alias_set properly. (vn_reference_lookup_3): Replace INDIRECT_REF handling with MEM_REF. (vn_reference_fold_indirect): Adjust for MEM_REFs. (valueize_refs): Fold MEM_REFs. Re-evaluate constant offset for ARRAY_REFs. (may_insert): Remove. (visit_reference_op_load): Do not test may_insert. (run_scc_vn): Remove parameter, do not fiddle with may_insert. * tree-ssa-sccvn.h (struct vn_reference_op_struct): Add a field to store the constant offset this op applies. (run_scc_vn): Adjust prototype. * cgraphunit.c (thunk_adjust): Adjust for MEM_REF. * tree-ssa-ccp.c (ccp_fold): Replace INDIRECT_REF folding with MEM_REF. Propagate &foo + CST as &MEM[&foo, CST]. Do not bother about volatile qualifiers on pointers. (fold_const_aggregate_ref): Handle MEM_REF, do not handle INDIRECT_REF. * tree-ssa-loop-ivopts.c * tree-ssa-loop-ivopts.c (determine_base_object): Adjust for MEM_REF. (strip_offset_1): Likewise. (find_interesting_uses_address): Replace INDIRECT_REF handling with MEM_REF handling. (get_computation_cost_at): Likewise. * ipa-pure-const.c (check_op): Handle MEM_REF. * tree-stdarg.c (check_all_va_list_escapes): Adjust for MEM_REF. * tree-ssa-sink.c (is_hidden_global_store): Handle MEM_REF and constants. * ipa-inline.c (likely_eliminated_by_inlining_p): Handle MEM_REF. * tree-parloops.c (take_address_of): Adjust for MEM_REF. (eliminate_local_variables_1): Likewise. (create_call_for_reduction_1): Likewise. (create_loads_for_reductions): Likewise. (create_loads_and_stores_for_name): Likewise. * matrix-reorg.c (may_flatten_matrices_1): Sanitize. (ssa_accessed_in_tree): Handle MEM_REF. (ssa_accessed_in_assign_rhs): Likewise. (update_type_size): Likewise. (analyze_accesses_for_call_stmt): Likewise. (analyze_accesses_for_assign_stmt): Likewise. (transform_access_sites): Likewise. (transform_allocation_sites): Likewise. * tree-affine.c (tree_to_aff_combination): Handle MEM_REF. * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref): Do not handle INDIRECT_REF. * tree-ssa-phiopt.c (add_or_mark_expr): Handle MEM_REF. (cond_store_replacement): Likewise. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Handle MEM_REF, no not handle INDIRECT_REFs. (insert_into_preds_of_block): Properly initialize avail. (phi_translate_1): Fold MEM_REFs. Re-evaluate constant offset for ARRAY_REFs. Properly handle reference lookups that require a bit re-interpretation. (can_PRE_operation): Do not handle INDIRECT_REF. Handle MEM_REF. * tree-sra.c * tree-sra.c (build_access_from_expr_1): Handle MEM_REF. (build_ref_for_offset_1): Remove. (build_ref_for_offset): Build MEM_REFs. (gate_intra_sra): Disable for now. (sra_ipa_modify_expr): Handle MEM_REF. (ipa_early_sra_gate): Disable for now. * tree-sra.c (create_access): Swap INDIRECT_REF handling for MEM_REF handling. (disqualify_base_of_expr): Likewise. (ptr_parm_has_direct_uses): Swap INDIRECT_REF handling for MEM_REF handling. (sra_ipa_modify_expr): Remove INDIRECT_REF handling. Use mem_ref_offset. Remove bogus folding. (build_access_from_expr_1): Properly handle MEM_REF for non IPA-SRA. (make_fancy_name_1): Add support for MEM_REF. * tree-predcom.c (ref_at_iteration): Handle MEM_REFs. * tree-mudflap.c (mf_xform_derefs_1): Adjust for MEM_REF. * ipa-prop.c (compute_complex_assign_jump_func): Handle MEM_REF. (compute_complex_ancestor_jump_func): Likewise. (ipa_analyze_virtual_call_uses): Likewise. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Replace INDIRECT_REF folding with more generalized MEM_REF folding. (tree_ssa_forward_propagate_single_use_vars): Adjust accordingly. (forward_propagate_addr_into_variable_array_index): Also handle &ARRAY + I in addition to &ARRAY[0] + I. * tree-ssa-dce.c (ref_may_be_aliased): Handle MEM_REF. * tree-ssa-ter.c (find_replaceable_in_bb): Avoid TER if that creates assignments with overlap. * tree-nested.c (get_static_chain): Adjust for MEM_REF. (get_frame_field): Likewise. (get_nonlocal_debug_decl): Likewise. (convert_nonlocal_reference_op): Likewise. (struct nesting_info): Add mem_refs pointer-set. (create_nesting_tree): Allocate it. (convert_local_reference_op): Insert to be folded mem-refs. (fold_mem_refs): New function. (finalize_nesting_tree_1): Perform defered folding of mem-refs (free_nesting_tree): Free the pointer-set. * tree-vect-stmts.c (vectorizable_store): Adjust for MEM_REF. (vectorizable_load): Likewise. * tree-ssa-phiprop.c (phiprop_insert_phi): Adjust for MEM_REF. (propagate_with_phi): Likewise. * tree-object-size.c (addr_object_size): Handle MEM_REFs instead of INDIRECT_REFs. (compute_object_offset): Handle MEM_REF. (plus_stmt_object_size): Handle MEM_REF. (collect_object_sizes_for): Dispatch to plus_stmt_object_size for &MEM_REF. * tree-flow.h (get_addr_base_and_unit_offset): Declare. (symbol_marked_for_renaming): Likewise. * Makefile.in (tree-dfa.o): Add $(TOPLEV_H). (fold-const.o): Add $(TREE_FLOW_H). * tree-ssa-structalias.c (get_constraint_for_1): Handle MEM_REF. (find_func_clobbers): Likewise. * ipa-struct-reorg.c (decompose_indirect_ref_acc): Handle MEM_REF. (decompose_access): Likewise. (replace_field_acc): Likewise. (replace_field_access_stmt): Likewise. (insert_new_var_in_stmt): Likewise. (get_stmt_accesses): Likewise. (reorg_structs_drive): Disable. * config/i386/i386.c (ix86_va_start): Adjust for MEM_REF. (ix86_canonical_va_list_type): Likewise. cp/ * cp-gimplify.c (cp_gimplify_expr): Open-code the rhs predicate we are looking for, allow non-gimplified INDIRECT_REFs. testsuite/ * gcc.c-torture/execute/20100316-1.c: New testcase. * gcc.c-torture/execute/pr44468.c: Likewise. * gcc.c-torture/compile/20100609-1.c: Likewise. * gcc.dg/volatile2.c: Adjust. * gcc.dg/plugin/selfassign.c: Likewise. * gcc.dg/pr36902.c: Likewise. * gcc.dg/tree-ssa/foldaddr-2.c: Remove. * gcc.dg/tree-ssa/foldaddr-3.c: Likewise. * gcc.dg/tree-ssa/forwprop-8.c: Adjust. * gcc.dg/tree-ssa/pr17141-1.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-13.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-14.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-21.c: Likewise. * gcc.dg/tree-ssa/pta-ptrarith-1.c: Likewise. * gcc.dg/tree-ssa/20030807-7.c: Likewise. * gcc.dg/tree-ssa/forwprop-10.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-1.c: Likewise. * gcc.dg/tree-ssa/pta-ptrarith-2.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-23.c: Likewise. * gcc.dg/tree-ssa/forwprop-1.c: Likewise. * gcc.dg/tree-ssa/forwprop-2.c: Likewise. * gcc.dg/tree-ssa/struct-aliasing-1.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-25.c: Likewise. * gcc.dg/tree-ssa/ssa-pre-26.c: Likewise. * gcc.dg/tree-ssa/struct-aliasing-2.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-26.c: Likewise. * gcc.dg/tree-ssa/ssa-sccvn-4.c: Likewise. * gcc.dg/tree-ssa/ssa-pre-7.c: Likewise. * gcc.dg/tree-ssa/forwprop-5.c: Likewise. * gcc.dg/struct/w_prof_two_strs.c: XFAIL. * gcc.dg/struct/wo_prof_escape_arg_to_local.c: Likewise. * gcc.dg/struct/wo_prof_global_var.c: Likewise. * gcc.dg/struct/wo_prof_malloc_size_var.c: Likewise. * gcc.dg/struct/w_prof_local_array.c: Likewise. * gcc.dg/struct/w_prof_single_str_global.c: Likewise. * gcc.dg/struct/wo_prof_escape_str_init.c: Likewise. * gcc.dg/struct/wo_prof_array_through_pointer.c: Likewise. * gcc.dg/struct/w_prof_global_array.c: Likewise. * gcc.dg/struct/wo_prof_array_field.c: Likewise. * gcc.dg/struct/wo_prof_single_str_local.c: Likewise. * gcc.dg/struct/w_prof_local_var.c: Likewise. * gcc.dg/struct/wo_prof_two_strs.c: Likewise. * gcc.dg/struct/wo_prof_empty_str.c: Likewise. * gcc.dg/struct/wo_prof_local_array.c: Likewise. * gcc.dg/struct/w_prof_global_var.c: Likewise. * gcc.dg/struct/wo_prof_single_str_global.c: Likewise. * gcc.dg/struct/wo_prof_escape_substr_value.c: Likewise. * gcc.dg/struct/wo_prof_global_array.c: Likewise. * gcc.dg/struct/wo_prof_escape_return.c: Likewise. * gcc.dg/struct/wo_prof_escape_substr_array.c: Likewise. * gcc.dg/struct/wo_prof_double_malloc.c: Likewise. * gcc.dg/struct/w_ratio_cold_str.c: Likewise. * gcc.dg/struct/wo_prof_escape_substr_pointer.c: Likewise. * gcc.dg/struct/wo_prof_local_var.c: Likewise. * gcc.dg/tree-prof/stringop-1.c: Adjust. * g++.dg/tree-ssa/pr31146.C: Likewise. * g++.dg/tree-ssa/copyprop-1.C: Likewise. * g++.dg/tree-ssa/pr33604.C: Likewise. * g++.dg/plugin/selfassign.c: Likewise. * gfortran.dg/array_memcpy_3.f90: Likewise. * gfortran.dg/array_memcpy_4.f90: Likewise. * c-c++-common/torture/pr42834.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161655 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 98 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 42 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f1470d7a384..3b1c459128f 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -811,48 +811,49 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) { /* Otherwise, just copy the node. Note that copy_tree_r already knows not to copy VAR_DECLs, etc., so this is safe. */ - if (TREE_CODE (*tp) == INDIRECT_REF) + if (TREE_CODE (*tp) == MEM_REF) { - /* Get rid of *& from inline substitutions that can happen when a - pointer argument is an ADDR_EXPR. */ + /* We need to re-canonicalize MEM_REFs from inline substitutions + that can happen when a pointer argument is an ADDR_EXPR. */ tree decl = TREE_OPERAND (*tp, 0); tree *n; n = (tree *) pointer_map_contains (id->decl_map, decl); if (n) { - tree type, new_tree, old; - - /* If we happen to get an ADDR_EXPR in n->value, strip - it manually here as we'll eventually get ADDR_EXPRs - which lie about their types pointed to. In this case - build_fold_indirect_ref wouldn't strip the - INDIRECT_REF, but we absolutely rely on that. As - fold_indirect_ref does other useful transformations, - try that first, though. */ - type = TREE_TYPE (TREE_TYPE (*n)); - new_tree = unshare_expr (*n); - old = *tp; - *tp = gimple_fold_indirect_ref (new_tree); - if (!*tp) - { - if (TREE_CODE (new_tree) == ADDR_EXPR) - { - *tp = fold_indirect_ref_1 (EXPR_LOCATION (new_tree), - type, new_tree); - /* ??? We should either assert here or build - a VIEW_CONVERT_EXPR instead of blindly leaking - incompatible types to our IL. */ - if (! *tp) - *tp = TREE_OPERAND (new_tree, 0); - } - else - { - *tp = build1 (INDIRECT_REF, type, new_tree); - TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); - TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); - } + tree old = *tp; + tree ptr = unshare_expr (*n); + tree tem; + if ((tem = maybe_fold_offset_to_reference (EXPR_LOCATION (*tp), + ptr, + TREE_OPERAND (*tp, 1), + TREE_TYPE (*tp))) + && TREE_THIS_VOLATILE (tem) == TREE_THIS_VOLATILE (old)) + { + tree *tem_basep = &tem; + while (handled_component_p (*tem_basep)) + tem_basep = &TREE_OPERAND (*tem_basep, 0); + if (TREE_CODE (*tem_basep) == MEM_REF) + *tem_basep + = build2 (MEM_REF, TREE_TYPE (*tem_basep), + TREE_OPERAND (*tem_basep, 0), + fold_convert (TREE_TYPE (TREE_OPERAND (*tp, 1)), + TREE_OPERAND (*tem_basep, 1))); + else + *tem_basep + = build2 (MEM_REF, TREE_TYPE (*tem_basep), + build_fold_addr_expr (*tem_basep), + build_int_cst + (TREE_TYPE (TREE_OPERAND (*tp, 1)), 0)); + *tp = tem; + } + else + { + *tp = fold_build2 (MEM_REF, TREE_TYPE (*tp), + ptr, TREE_OPERAND (*tp, 1)); + TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); } + TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); *walk_subtrees = 0; return NULL; } @@ -887,7 +888,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) else if (TREE_CODE (*tp) == ADDR_EXPR) { /* Variable substitution need not be simple. In particular, - the INDIRECT_REF substitution above. Make sure that + the MEM_REF substitution above. Make sure that TREE_CONSTANT and friends are up-to-date. But make sure to not improperly set TREE_BLOCK on some sub-expressions. */ int invariant = is_gimple_min_invariant (*tp); @@ -895,13 +896,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) id->block = NULL_TREE; walk_tree (&TREE_OPERAND (*tp, 0), remap_gimple_op_r, data, NULL); id->block = block; - - /* Handle the case where we substituted an INDIRECT_REF - into the operand of the ADDR_EXPR. */ - if (TREE_CODE (TREE_OPERAND (*tp, 0)) == INDIRECT_REF) - *tp = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0); - else - recompute_tree_invariant_for_addr_expr (*tp); + recompute_tree_invariant_for_addr_expr (*tp); /* If this used to be invariant, but is not any longer, then regimplification is probably needed. */ @@ -1092,6 +1087,25 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) return NULL; } } + else if (TREE_CODE (*tp) == MEM_REF) + { + /* We need to re-canonicalize MEM_REFs from inline substitutions + that can happen when a pointer argument is an ADDR_EXPR. */ + tree decl = TREE_OPERAND (*tp, 0); + tree *n; + + n = (tree *) pointer_map_contains (id->decl_map, decl); + if (n) + { + tree old = *tp; + *tp = fold_build2 (MEM_REF, TREE_TYPE (*tp), + unshare_expr (*n), TREE_OPERAND (*tp, 1)); + TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); + TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); + *walk_subtrees = 0; + return NULL; + } + } /* Here is the "usual case". Copy this tree node, and then tweak some special cases. */ -- cgit v1.2.1 From bc6af3fe93d454e9b47d68317c8998413e9e9469 Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 4 Jul 2010 12:20:14 +0000 Subject: 2010-07-04 Richard Guenther PR middle-end/44785 * tree-inline.c (initialize_inlined_parameters): Do not re-use pointer-map slot over remap_type call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161800 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 3b1c459128f..46c604f08fd 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2690,19 +2690,20 @@ initialize_inlined_parameters (copy_body_data *id, gimple stmt, if (varp && TREE_CODE (*varp) == VAR_DECL) { - tree def = (gimple_in_ssa_p (cfun) + tree def = (gimple_in_ssa_p (cfun) && is_gimple_reg (p) ? gimple_default_def (id->src_cfun, p) : NULL); - TREE_TYPE (*varp) = remap_type (TREE_TYPE (*varp), id); + tree var = *varp; + TREE_TYPE (var) = remap_type (TREE_TYPE (var), id); /* Also remap the default definition if it was remapped to the default definition of the parameter replacement by the parameter setup. */ - if (def && gimple_in_ssa_p (cfun) && is_gimple_reg (p)) + if (def) { tree *defp = (tree *) pointer_map_contains (id->decl_map, def); if (defp && TREE_CODE (*defp) == SSA_NAME - && SSA_NAME_VAR (*defp) == *varp) - TREE_TYPE (*defp) = TREE_TYPE (*varp); + && SSA_NAME_VAR (*defp) == var) + TREE_TYPE (*defp) = TREE_TYPE (var); } } } -- cgit v1.2.1 From 2ab2ce89368289e93c9022aae8689f109c132f5c Mon Sep 17 00:00:00 2001 From: froydnj Date: Tue, 6 Jul 2010 02:26:33 +0000 Subject: gcc/ * vec.h (FOR_EACH_VEC_ELT_REVERSE): New macro. * function.h (struct_function): Change type of local_decls field to a VEC. (add_local_decl): New function. (FOR_EACH_LOCAL_DECL): New macro. * cfgexpand.c (init_vars_expansion): Adjust for new type of cfun->local_decls. (estimated_stack_frame_size): Likewise. (expand_used_vars): Likewise. * cgraphbuild.c (build_cgraph_edges): Likewise. * function.c (instantiate_decls_1): Likewise. * ipa-struct-reorg.c (build_data_structure): Likewise. * ipa-type-escape.c (analyze_function): Likewise. * lto-streamer-in.c (input_function): Likewise. * lto-streamer-out.c (output_function): Likewise. * tree-ssa-live.c (remove_unused_locals): Likewise. * tree.c (free_lang_data_in_decl): Likewise. (find_decls_types_in_node): Likewise. * omp-low.c (remove_exit_barrier): Likewise. (expand_omp_taskreg): Likewise. (list2chain): Rename to... (vec2chain): ...this. Adjust. * cgraphunit.c (assemble_thunk): Call add_local_decl. * tree-cfg.c (replace_by_duplicate_decl): Likewise. * gimple-low.c (record_vars_into): Likewise. * tree-inline.c (remap_decls): Likewise. (declare_return_variable): Likewise. (declare_inline_vars): Likewise. (copy_forbidden): Adjust for new type of cfun->local_decls. (add_local_variables): New function. (expand_call_inline): Call it. (tree_function_versioning): Likewise. gcc/cp/ * decl.c (cp_finish_decl): Call add_local_decl. * optimize.c (clone_body): Adjust for new type of cfun->local_decls. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161862 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 94 ++++++++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 53 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 46c604f08fd..e295a6a5890 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -545,8 +545,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) if (TREE_CODE (old_var) == VAR_DECL && ! DECL_EXTERNAL (old_var) && (var_ann (old_var) || !gimple_in_ssa_p (cfun))) - cfun->local_decls = tree_cons (NULL_TREE, old_var, - cfun->local_decls); + add_local_decl (cfun, old_var); if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) && !DECL_IGNORED_P (old_var) && nonlocalized_list) @@ -2854,9 +2853,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) } DECL_SEEN_IN_BIND_EXPR_P (var) = 1; - DECL_STRUCT_FUNCTION (caller)->local_decls - = tree_cons (NULL_TREE, var, - DECL_STRUCT_FUNCTION (caller)->local_decls); + add_local_decl (DECL_STRUCT_FUNCTION (caller), var); /* Do not have the rest of GCC warn about this variable as it should not be visible to the user. */ @@ -2915,7 +2912,8 @@ static const char * copy_forbidden (struct function *fun, tree fndecl) { const char *reason = fun->cannot_be_copied_reason; - tree step; + tree decl; + unsigned ix; /* Only examine the function once. */ if (fun->cannot_be_copied_set) @@ -2934,23 +2932,19 @@ copy_forbidden (struct function *fun, tree fndecl) goto fail; } - for (step = fun->local_decls; step; step = TREE_CHAIN (step)) - { - tree decl = TREE_VALUE (step); - - if (TREE_CODE (decl) == VAR_DECL - && TREE_STATIC (decl) - && !DECL_EXTERNAL (decl) - && DECL_INITIAL (decl) - && walk_tree_without_duplicates (&DECL_INITIAL (decl), - has_label_address_in_static_1, - fndecl)) - { - reason = G_("function %q+F can never be copied because it saves " - "address of local label in a static variable"); - goto fail; - } - } + FOR_EACH_LOCAL_DECL (fun, ix, decl) + if (TREE_CODE (decl) == VAR_DECL + && TREE_STATIC (decl) + && !DECL_EXTERNAL (decl) + && DECL_INITIAL (decl) + && walk_tree_without_duplicates (&DECL_INITIAL (decl), + has_label_address_in_static_1, + fndecl)) + { + reason = G_("function %q+F can never be copied because it saves " + "address of local label in a static variable"); + goto fail; + } fail: fun->cannot_be_copied_reason = reason; @@ -3737,6 +3731,26 @@ prepend_lexical_block (tree current_block, tree new_block) BLOCK_SUPERCONTEXT (new_block) = current_block; } +/* Add local variables from CALLEE to CALLER. */ + +static inline void +add_local_variables (struct function *callee, struct function *caller, + copy_body_data *id, bool check_var_ann) +{ + tree var; + unsigned ix; + + FOR_EACH_LOCAL_DECL (callee, ix, var) + if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) + { + if (!check_var_ann + || (var_ann (var) && add_referenced_var (var))) + add_local_decl (caller, var); + } + else if (!can_be_nonlocal (var, id)) + add_local_decl (caller, remap_decl (var, id)); +} + /* Fetch callee declaration from the call graph edge going from NODE and associated with STMR call statement. Return NULL_TREE if not found. */ static tree @@ -3769,8 +3783,6 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) gimple_stmt_iterator gsi, stmt_gsi; bool successfully_inlined = FALSE; bool purge_dead_abnormal_edges; - tree t_step; - tree var; /* Set input_location here so we get the right instantiation context if we call instantiate_decl from inlinable_function_p. */ @@ -3974,20 +3986,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) use_retvar = declare_return_variable (id, return_slot, modify_dest); /* Add local vars in this inlined callee to caller. */ - t_step = id->src_cfun->local_decls; - for (; t_step; t_step = TREE_CHAIN (t_step)) - { - var = TREE_VALUE (t_step); - if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) - { - if (var_ann (var) && add_referenced_var (var)) - cfun->local_decls = tree_cons (NULL_TREE, var, - cfun->local_decls); - } - else if (!can_be_nonlocal (var, id)) - cfun->local_decls = tree_cons (NULL_TREE, remap_decl (var, id), - cfun->local_decls); - } + add_local_variables (id->src_cfun, cfun, id, true); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -4729,7 +4728,7 @@ declare_inline_vars (tree block, tree vars) { DECL_SEEN_IN_BIND_EXPR_P (t) = 1; gcc_assert (!TREE_STATIC (t) && !TREE_ASM_WRITTEN (t)); - cfun->local_decls = tree_cons (NULL_TREE, t, cfun->local_decls); + add_local_decl (cfun, t); } if (block) @@ -5060,7 +5059,6 @@ tree_function_versioning (tree old_decl, tree new_decl, basic_block old_entry_block, bb; VEC (gimple, heap) *init_stmts = VEC_alloc (gimple, heap, 10); - tree t_step; tree old_current_function_decl = current_function_decl; tree vars = NULL_TREE; @@ -5185,19 +5183,9 @@ tree_function_versioning (tree old_decl, tree new_decl, declare_inline_vars (DECL_INITIAL (new_decl), vars); - if (DECL_STRUCT_FUNCTION (old_decl)->local_decls != NULL_TREE) + if (!VEC_empty (tree, DECL_STRUCT_FUNCTION (old_decl)->local_decls)) /* Add local vars. */ - for (t_step = DECL_STRUCT_FUNCTION (old_decl)->local_decls; - t_step; t_step = TREE_CHAIN (t_step)) - { - tree var = TREE_VALUE (t_step); - if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) - cfun->local_decls = tree_cons (NULL_TREE, var, cfun->local_decls); - else if (!can_be_nonlocal (var, &id)) - cfun->local_decls = - tree_cons (NULL_TREE, remap_decl (var, &id), - cfun->local_decls); - } + add_local_variables (DECL_STRUCT_FUNCTION (old_decl), cfun, &id, false); /* Copy the Function's body. */ copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE, -- cgit v1.2.1 From 524a05313c645ed67701d7de7837bc5fa65d3104 Mon Sep 17 00:00:00 2001 From: hubicka Date: Wed, 7 Jul 2010 01:00:42 +0000 Subject: PR middle-end/44813 * tree-ssa-uninit.c (ssa_undefined_value_p): Result decl is defined for functions passed by reference. * tree.c (needs_to_live_in_memory): RESULT_DECL don't need to live in memory when passed by reference. * tree-ssa-ccp.c (get_default_value): Only VAR_DECL is undefined at beggining. * ipa-split.c (split_function): Cleanup way return value is passed; handle SSA DECL_BY_REFERENCE retvals. * tree-ssa.c (verify_def): Verify that RESULT_DECL is read only when DECL_BY_REFERENCE is set. * tree-ssa-structalias.c (get_constraint_for_ssa_var, get_fi_for_callee, find_what_p_points_to): Handle RESULT_DECL. * tree-inline.c (declare_return_variable): Get new entry_block argument; when passing by reference ensure that RESULT_DECL is gimple_val. (remap_gimple_op_r): Remap RESULT_DECL ssa name. (remap_gimple_stmt): Handle SSA DECL_BY_REFERENCE returns. * g++.dg/torture/pr44813.C: New testcase. * g++.dg/torture/pr44826.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161898 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e295a6a5890..98caddebfba 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -113,7 +113,7 @@ eni_weights eni_time_weights; /* Prototypes. */ -static tree declare_return_variable (copy_body_data *, tree, tree); +static tree declare_return_variable (copy_body_data *, tree, tree, basic_block); static void remap_block (tree *, copy_body_data *); static void copy_bind_expr (tree *, int *, copy_body_data *); static tree mark_local_for_remap_r (tree *, int *, void *); @@ -817,6 +817,12 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) tree decl = TREE_OPERAND (*tp, 0); tree *n; + /* See remap_ssa_name. */ + if (TREE_CODE (decl) == SSA_NAME + && TREE_CODE (SSA_NAME_VAR (decl)) == RESULT_DECL + && id->transform_return_to_modify) + decl = SSA_NAME_VAR (decl); + n = (tree *) pointer_map_contains (id->decl_map, decl); if (n) { @@ -1235,7 +1241,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) If RETVAL is just the result decl, the result decl has already been set (e.g. a recent "foo (&result_decl, ...)"); just toss the entire GIMPLE_RETURN. */ - if (retval && TREE_CODE (retval) != RESULT_DECL) + if (retval + && (TREE_CODE (retval) != RESULT_DECL + && (TREE_CODE (retval) != SSA_NAME + || TREE_CODE (SSA_NAME_VAR (retval)) != RESULT_DECL))) { copy = gimple_build_assign (id->retvar, retval); /* id->retvar is already substituted. Skip it on later remapping. */ @@ -2735,7 +2744,8 @@ initialize_inlined_parameters (copy_body_data *id, gimple stmt, as seen by the caller. */ static tree -declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) +declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, + basic_block entry_bb) { tree callee = id->src_fn; tree caller = id->dst_fn; @@ -2878,8 +2888,20 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) done: /* Register the VAR_DECL as the equivalent for the RESULT_DECL; that way, when the RESULT_DECL is encountered, it will be - automatically replaced by the VAR_DECL. */ - insert_decl_map (id, result, var); + automatically replaced by the VAR_DECL. + + When returning by reference, ensure that RESULT_DECL remaps to + gimple_val. */ + if (DECL_BY_REFERENCE (result) + && !is_gimple_val (var)) + { + tree temp = create_tmp_var (TREE_TYPE (result), "retvalptr"); + insert_decl_map (id, result, temp); + temp = remap_ssa_name (gimple_default_def (id->src_cfun, result), id); + insert_init_stmt (id, entry_bb, gimple_build_assign (temp, var)); + } + else + insert_decl_map (id, result, var); /* Remember this so we can ignore it in remap_decls. */ id->retvar = var; @@ -3983,7 +4005,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) } /* Declare the return variable for the function. */ - use_retvar = declare_return_variable (id, return_slot, modify_dest); + use_retvar = declare_return_variable (id, return_slot, modify_dest, bb); /* Add local vars in this inlined callee to caller. */ add_local_variables (id->src_cfun, cfun, id, true); -- cgit v1.2.1 From 0b205f4ca112a643f4f1b9c9886648b569e0b380 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 8 Jul 2010 04:22:54 +0000 Subject: =?UTF-8?q?2010-07-08=20=20Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez=20?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * toplev.h: Do not include diagnostic-core.h. Include diagnostic-core.h in every file that includes toplev.h. * c-tree.h: Do not include toplev.h. * pretty-print.h: Update comment. * Makefile.in: Update dependencies. * alias.c: Include diagnostic-core.h in every file that includes toplev.h. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgbuild.c: Likewise. * cfgcleanup.c: Likewise. * cfghooks.c: Likewise. * cfgloop.c: Likewise. * combine.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/arm/pe.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/cris/cris.c: Likewise. * config/crx/crx.c: Likewise. * config/darwin-c.c: Likewise. * config/darwin.c: Likewise. * config/fr30/fr30.c: Likewise. * config/frv/frv.c: Likewise. * config/h8300/h8300.c: Likewise. * config/host-darwin.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/netware.c: Likewise. * config/i386/nwld.c: Likewise. * config/i386/winnt-cxx.c: Likewise. * config/i386/winnt-stubs.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64-c.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/lm32/lm32.c: Likewise. * config/m32c/m32c-pragma.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68hc11/m68hc11.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/mep/mep-pragma.c: Likewise. * config/mep/mep.c: Likewise. * config/mmix/mmix.c: Likewise. * config/mn10300/mn10300.c: Likewise. * config/moxie/moxie.c: Likewise. * config/pa/pa.c: Likewise. * config/pdp11/pdp11.c: Likewise. * config/picochip/picochip.c: Likewise. * config/rs6000/rs6000-c.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/rx/rx.c: Likewise. * config/s390/s390.c: Likewise. * config/score/score.c: Likewise. * config/score/score3.c: Likewise. * config/score/score7.c: Likewise. * config/sh/sh.c: Likewise. * config/sh/symbian-base.c: Likewise. * config/sh/symbian-c.c: Likewise. * config/sh/symbian-cxx.c: Likewise. * config/sol2-c.c: Likewise. * config/sol2.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/v850/v850-c.c: Likewise. * config/v850/v850.c: Likewise. * config/vax/vax.c: Likewise. * config/vxworks.c: Likewise. * config/xtensa/xtensa.c: Likewise. * convert.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dbgcnt.c: Likewise. * dbxout.c: Likewise. * ddg.c: Likewise. * dominance.c: Likewise. * emit-rtl.c: Likewise. * explow.c: Likewise. * expmed.c: Likewise. * fixed-value.c: Likewise. * fold-const.c: Likewise. * fwprop.c: Likewise. * gcse.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * ggc-zone.c: Likewise. * gimple-low.c: Likewise. * gimplify.c: Likewise. * graph.c: Likewise. * haifa-sched.c: Likewise. * ifcvt.c: Likewise. * implicit-zee.c: Likewise. * integrate.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-iv.c: Likewise. * lto-opts.c: Likewise. * lto-symtab.c: Likewise. * main.c: Likewise. * modulo-sched.c: Likewise. * optabs.c: Likewise. * params.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * profile.c: Likewise. * real.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regmove.c: Likewise. * reorg.c: Likewise. * resource.c: Likewise. * rtl.c: Likewise. * rtlanal.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-rgn.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * simplify-rtx.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * targhooks.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-dump.c: Likewise. * tree-eh.c: Likewise. * tree-inline.c: Likewise. * tree-nomudflap.c: Likewise. * tree-object-size.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-phinodes.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-ssa.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * varasm.c: Likewise. * vec.c: Likewise. * web.c: Likewise. * xcoffout.c: Likewise. c-family/ * c-common.h: Include diagnostic-core.h. Error if already included. * c-semantics.c: Do not define GCC_DIAG_STYLE here. cp/ * cp-tree.h: Do not include toplev.h. java/ * boehm.c: Include diagnostic-core.h in every file that includes toplev.h. * class.c: Likewise. * constants.c: Likewise. * decl.c: Likewise. * except.c: Likewise. * expr.c: Likewise. * jcf-parse.c: Likewise. * mangle.c: Likewise. * mangle_name.c: Likewise. * resource.c: Likewise. * typeck.c: Likewise. * verify-glue.c: Likewise. ada/ * gcc-interface/utils.c: Include diagnostic-core.h in every file that includes toplev.h. lto/ * lto-coff.c: Include diagnostic-core.h in every file that includes toplev.h. * lto-elf.c: Likewise. * lto-lang.c: Likewise. * lto-macho.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161943 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 98caddebfba..ea891c94e55 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -23,7 +23,8 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "tm.h" -#include "toplev.h" +#include "toplev.h" /* floor_log2 */ +#include "diagnostic-core.h" #include "tree.h" #include "tree-inline.h" #include "flags.h" -- cgit v1.2.1 From 1aeb48b84fa01fb527d64b78bc0a6533e027d6da Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 8 Jul 2010 16:44:54 +0000 Subject: * tree-inline.c (declare_return_variable): Allocate annotation for new temporary. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161965 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ea891c94e55..069dcb3006d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2897,6 +2897,11 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, && !is_gimple_val (var)) { tree temp = create_tmp_var (TREE_TYPE (result), "retvalptr"); + if (gimple_in_ssa_p (id->src_cfun)) + { + get_var_ann (temp); + add_referenced_var (temp); + } insert_decl_map (id, result, temp); temp = remap_ssa_name (gimple_default_def (id->src_cfun, result), id); insert_init_stmt (id, entry_bb, gimple_build_assign (temp, var)); -- cgit v1.2.1 From 883fe359862dfc9b4a7971ff9cc7435d972419a6 Mon Sep 17 00:00:00 2001 From: hubicka Date: Fri, 9 Jul 2010 23:41:10 +0000 Subject: * tree-inline.c (declare_return_variable): Fix ICE while inlining DECL_BY_VALUE function not in SSA form git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162024 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 069dcb3006d..57364e43721 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2903,7 +2903,10 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, add_referenced_var (temp); } insert_decl_map (id, result, temp); - temp = remap_ssa_name (gimple_default_def (id->src_cfun, result), id); + /* When RESULT_DECL is in SSA form, we need to use it's default_def + SSA_NAME. */ + if (gimple_in_ssa_p (id->src_cfun) && gimple_default_def (id->src_cfun, result)) + temp = remap_ssa_name (gimple_default_def (id->src_cfun, result), id); insert_init_stmt (id, entry_bb, gimple_build_assign (temp, var)); } else -- cgit v1.2.1 From a6b74a67c831c6d371d91dbbeda762fb01ff180c Mon Sep 17 00:00:00 2001 From: sandra Date: Sat, 10 Jul 2010 18:43:29 +0000 Subject: 2010-07-10 Sandra Loosemore PR middle-end/42505 gcc/ * tree-inline.c (estimate_num_insns): Refactor builtin complexity lookup code into.... * builtins.c (is_simple_builtin, is_inexpensive_builtin): ...these new functions. * tree.h (is_simple_builtin, is_inexpensive_builtin): Declare. * cfgloopanal.c (target_clobbered_regs): Define. (init_set_costs): Initialize target_clobbered_regs. (estimate_reg_pressure_cost): Add call_p argument. When true, adjust the number of available registers to exclude the call-clobbered registers. * cfgloop.h (target_clobbered_regs): Declare. (estimate_reg_pressure_cost): Adjust declaration. * tree-ssa-loop-ivopts.c (struct ivopts_data): Add body_includes_call. (ivopts_global_cost_for_size): Pass it to estimate_reg_pressure_cost. (determine_set_costs): Dump target_clobbered_regs. (loop_body_includes_call): New function. (tree_ssa_iv_optimize_loop): Use it to initialize new field. * loop-invariant.c (gain_for_invariant): Adjust arguments to pass call_p flag through. (best_gain_for_invariant): Likewise. (find_invariants_to_move): Likewise. (move_single_loop_invariants): Likewise, using already-computed has_call field. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162043 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 98 ++----------------------------------------------------- 1 file changed, 3 insertions(+), 95 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 57364e43721..4298958fb51 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3478,105 +3478,13 @@ estimate_num_insns (gimple stmt, eni_weights *weights) if (POINTER_TYPE_P (funtype)) funtype = TREE_TYPE (funtype); - if (decl && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_MD) + if (is_simple_builtin (decl)) + return 0; + else if (is_inexpensive_builtin (decl)) cost = weights->target_builtin_call_cost; else cost = weights->call_cost; - if (decl && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) - switch (DECL_FUNCTION_CODE (decl)) - { - /* Builtins that expand to constants. */ - case BUILT_IN_CONSTANT_P: - case BUILT_IN_EXPECT: - case BUILT_IN_OBJECT_SIZE: - case BUILT_IN_UNREACHABLE: - /* Simple register moves or loads from stack. */ - case BUILT_IN_RETURN_ADDRESS: - case BUILT_IN_EXTRACT_RETURN_ADDR: - case BUILT_IN_FROB_RETURN_ADDR: - case BUILT_IN_RETURN: - case BUILT_IN_AGGREGATE_INCOMING_ADDRESS: - case BUILT_IN_FRAME_ADDRESS: - case BUILT_IN_VA_END: - case BUILT_IN_STACK_SAVE: - case BUILT_IN_STACK_RESTORE: - /* Exception state returns or moves registers around. */ - case BUILT_IN_EH_FILTER: - case BUILT_IN_EH_POINTER: - case BUILT_IN_EH_COPY_VALUES: - return 0; - - /* builtins that are not expensive (that is they are most probably - expanded inline into resonably simple code). */ - case BUILT_IN_ABS: - case BUILT_IN_ALLOCA: - case BUILT_IN_BSWAP32: - case BUILT_IN_BSWAP64: - case BUILT_IN_CLZ: - case BUILT_IN_CLZIMAX: - case BUILT_IN_CLZL: - case BUILT_IN_CLZLL: - case BUILT_IN_CTZ: - case BUILT_IN_CTZIMAX: - case BUILT_IN_CTZL: - case BUILT_IN_CTZLL: - case BUILT_IN_FFS: - case BUILT_IN_FFSIMAX: - case BUILT_IN_FFSL: - case BUILT_IN_FFSLL: - case BUILT_IN_IMAXABS: - case BUILT_IN_FINITE: - case BUILT_IN_FINITEF: - case BUILT_IN_FINITEL: - case BUILT_IN_FINITED32: - case BUILT_IN_FINITED64: - case BUILT_IN_FINITED128: - case BUILT_IN_FPCLASSIFY: - case BUILT_IN_ISFINITE: - case BUILT_IN_ISINF_SIGN: - case BUILT_IN_ISINF: - case BUILT_IN_ISINFF: - case BUILT_IN_ISINFL: - case BUILT_IN_ISINFD32: - case BUILT_IN_ISINFD64: - case BUILT_IN_ISINFD128: - case BUILT_IN_ISNAN: - case BUILT_IN_ISNANF: - case BUILT_IN_ISNANL: - case BUILT_IN_ISNAND32: - case BUILT_IN_ISNAND64: - case BUILT_IN_ISNAND128: - case BUILT_IN_ISNORMAL: - case BUILT_IN_ISGREATER: - case BUILT_IN_ISGREATEREQUAL: - case BUILT_IN_ISLESS: - case BUILT_IN_ISLESSEQUAL: - case BUILT_IN_ISLESSGREATER: - case BUILT_IN_ISUNORDERED: - case BUILT_IN_VA_ARG_PACK: - case BUILT_IN_VA_ARG_PACK_LEN: - case BUILT_IN_VA_COPY: - case BUILT_IN_TRAP: - case BUILT_IN_SAVEREGS: - case BUILT_IN_POPCOUNTL: - case BUILT_IN_POPCOUNTLL: - case BUILT_IN_POPCOUNTIMAX: - case BUILT_IN_POPCOUNT: - case BUILT_IN_PARITYL: - case BUILT_IN_PARITYLL: - case BUILT_IN_PARITYIMAX: - case BUILT_IN_PARITY: - case BUILT_IN_LABS: - case BUILT_IN_LLABS: - case BUILT_IN_PREFETCH: - cost = weights->target_builtin_call_cost; - break; - - default: - break; - } - if (decl) funtype = TREE_TYPE (decl); -- cgit v1.2.1 From 1767a056f10a2ccbc900df04d01193da73a3d272 Mon Sep 17 00:00:00 2001 From: froydnj Date: Thu, 15 Jul 2010 14:31:28 +0000 Subject: gcc/ * tree.h (DECL_CHAIN): Define. * alias.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-decl.c: Likewise. * c-parser.c: Likewise. * c-typeck.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arm/arm.c: Likewise. * config/frv/frv.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/winnt-cxx.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/pa/som.h: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sh/symbian-cxx.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/vxworks.c: Likewise. * config/xtensa/xtensa.c: Likewise. * coverage.c: Likewise. * dbxout.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimplify.c: Likewise. * integrate.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-split.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-type-escape.c: Likewise. * langhooks.c: Likewise. * lto-cgraph.c: Likewise. * omp-low.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-complex.c: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-inline.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-object-size.c: Likewise. * tree-pretty-print.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-tailcall.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. * gcc-interface/utils2.c: Likewise. gcc/c-family/ * c-common.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-format.c: Likewise. gcc/cp/ * cp-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * call.c: Likewise. * class.c: Likewise. * cp-gimplify.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * init.c: Likewise. * mangle.c: Likewise. * name-lookup.c: Likewise. * optimize.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * rtti.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * f95-lang.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * trans-common.c: Likewise. * trans-decl.c: Likewise. * trans-types.c: Likewise. * trans.c: Likewise. gcc/java/ * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * boehm.c: Likewise. * class.c: Likewise. * decl.c: Likewise. * expr.c: Likewise. * jcf-parse.c: Likewise. * typeck.c: Likewise. * verify-glue.c: Likewise. gcc/objc/ * objc-act.c: Carefully replace TREE_CHAIN with DECL_CHAIN. gcc/testsuite/ * g++.dg/plugin/attribute_plugin.c: Carefully replace TREE_CHAIN with DECL_CHAIN. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162223 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 4298958fb51..5b429eb5485 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -422,11 +422,11 @@ remap_type_1 (tree type, copy_body_data *id) { tree f, nf = NULL; - for (f = TYPE_FIELDS (new_tree); f ; f = TREE_CHAIN (f)) + for (f = TYPE_FIELDS (new_tree); f ; f = DECL_CHAIN (f)) { t = remap_decl (f, id); DECL_CONTEXT (t) = new_tree; - TREE_CHAIN (t) = nf; + DECL_CHAIN (t) = nf; nf = t; } TYPE_FIELDS (new_tree) = nreverse (nf); @@ -537,7 +537,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) tree new_decls = NULL_TREE; /* Remap its variables. */ - for (old_var = decls; old_var; old_var = TREE_CHAIN (old_var)) + for (old_var = decls; old_var; old_var = DECL_CHAIN (old_var)) { tree new_var; @@ -573,7 +573,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) else { gcc_assert (DECL_P (new_var)); - TREE_CHAIN (new_var) = new_decls; + DECL_CHAIN (new_var) = new_decls; new_decls = new_var; /* Also copy value-expressions. */ @@ -1595,7 +1595,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, size_t nargs = gimple_call_num_args (id->gimple_call); size_t n; - for (p = DECL_ARGUMENTS (id->src_fn); p; p = TREE_CHAIN (p)) + for (p = DECL_ARGUMENTS (id->src_fn); p; p = DECL_CHAIN (p)) nargs--; /* Create the new array of arguments. */ @@ -1642,7 +1642,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, tree count, p; gimple new_stmt; - for (p = DECL_ARGUMENTS (id->src_fn); p; p = TREE_CHAIN (p)) + for (p = DECL_ARGUMENTS (id->src_fn); p; p = DECL_CHAIN (p)) nargs--; count = build_int_cst (integer_type_node, nargs); @@ -2553,7 +2553,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, } /* Declare this new variable. */ - TREE_CHAIN (var) = *vars; + DECL_CHAIN (var) = *vars; *vars = var; /* Make gimplifier happy about this variable. */ @@ -2683,7 +2683,7 @@ initialize_inlined_parameters (copy_body_data *id, gimple stmt, /* Loop through the parameter declarations, replacing each with an equivalent VAR_DECL, appropriately initialized. */ - for (p = parms, i = 0; p; p = TREE_CHAIN (p), i++) + for (p = parms, i = 0; p; p = DECL_CHAIN (p), i++) { tree val; val = i < gimple_call_num_args (stmt) ? gimple_call_arg (stmt, i) : NULL; @@ -2693,7 +2693,7 @@ initialize_inlined_parameters (copy_body_data *id, gimple stmt, in a second loop over all parameters to appropriately remap variable sized arrays when the size is specified in a parameter following the array. */ - for (p = parms, i = 0; p; p = TREE_CHAIN (p), i++) + for (p = parms, i = 0; p; p = DECL_CHAIN (p), i++) { tree *varp = (tree *) pointer_map_contains (id->decl_map, p); if (varp @@ -3505,7 +3505,7 @@ estimate_num_insns (gimple stmt, eni_weights *weights) if (decl && DECL_ARGUMENTS (decl) && !stdarg) { tree arg; - for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg)) + for (arg = DECL_ARGUMENTS (decl); arg; arg = DECL_CHAIN (arg)) if (!VOID_TYPE_P (TREE_TYPE (arg))) cost += estimate_move_cost (TREE_TYPE (arg)); } @@ -4663,7 +4663,7 @@ static void declare_inline_vars (tree block, tree vars) { tree t; - for (t = vars; t; t = TREE_CHAIN (t)) + for (t = vars; t; t = DECL_CHAIN (t)) { DECL_SEEN_IN_BIND_EXPR_P (t) = 1; gcc_assert (!TREE_STATIC (t) && !TREE_ASM_WRITTEN (t)); @@ -4812,13 +4812,13 @@ copy_arguments_for_versioning (tree orig_parm, copy_body_data * id, parg = &new_parm; - for (arg = orig_parm; arg; arg = TREE_CHAIN (arg), i++) + for (arg = orig_parm; arg; arg = DECL_CHAIN (arg), i++) if (!args_to_skip || !bitmap_bit_p (args_to_skip, i)) { tree new_tree = remap_decl (arg, id); lang_hooks.dup_lang_specific_decl (new_tree); *parg = new_tree; - parg = &TREE_CHAIN (new_tree); + parg = &DECL_CHAIN (new_tree); } else if (!pointer_map_contains (id->decl_map, arg)) { @@ -4830,7 +4830,7 @@ copy_arguments_for_versioning (tree orig_parm, copy_body_data * id, add_referenced_var (var); insert_decl_map (id, arg, var); /* Declare this new variable. */ - TREE_CHAIN (var) = *vars; + DECL_CHAIN (var) = *vars; *vars = var; } return new_parm; @@ -4843,11 +4843,11 @@ copy_static_chain (tree static_chain, copy_body_data * id) tree *chain_copy, *pvar; chain_copy = &static_chain; - for (pvar = chain_copy; *pvar; pvar = &TREE_CHAIN (*pvar)) + for (pvar = chain_copy; *pvar; pvar = &DECL_CHAIN (*pvar)) { tree new_tree = remap_decl (*pvar, id); lang_hooks.dup_lang_specific_decl (new_tree); - TREE_CHAIN (new_tree) = TREE_CHAIN (*pvar); + DECL_CHAIN (new_tree) = DECL_CHAIN (*pvar); *pvar = new_tree; } return static_chain; @@ -5081,7 +5081,7 @@ tree_function_versioning (tree old_decl, tree new_decl, { int i = replace_info->parm_num; tree parm; - for (parm = DECL_ARGUMENTS (old_decl); i; parm = TREE_CHAIN (parm)) + for (parm = DECL_ARGUMENTS (old_decl); i; parm = DECL_CHAIN (parm)) i --; replace_info->old_tree = parm; } @@ -5220,7 +5220,7 @@ maybe_inline_call_in_expr (tree exp) /* Remap the parameters. */ for (param = DECL_ARGUMENTS (fn), arg = first_call_expr_arg (exp, &iter); param; - param = TREE_CHAIN (param), arg = next_call_expr_arg (&iter)) + param = DECL_CHAIN (param), arg = next_call_expr_arg (&iter)) *pointer_map_insert (decl_map, param) = arg; memset (&id, 0, sizeof (id)); -- cgit v1.2.1 From 1a036a3b458c7df845106c84ed9207bdd077c28f Mon Sep 17 00:00:00 2001 From: jamborm Date: Thu, 22 Jul 2010 09:33:11 +0000 Subject: 2010-07-22 Martin Jambor * cgraphunit.c (verify_edge_count_and_frequency): New function. (verify_cgraph_node): Verify frequencies of indirect edges. * tree-inline.c (tree_function_versioning): Update frequencies of indirect edges. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162406 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-inline.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gcc/tree-inline.c') diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 5b429eb5485..dc09c29b6ea 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -5184,7 +5184,15 @@ tree_function_versioning (tree old_decl, tree new_decl, for (e = new_version_node->callees; e; e = e->next_callee) { basic_block bb = gimple_bb (e->call_stmt); - e->frequency = compute_call_stmt_bb_frequency (current_function_decl, bb); + e->frequency = compute_call_stmt_bb_frequency (current_function_decl, + bb); + e->count = bb->count; + } + for (e = new_version_node->indirect_calls; e; e = e->next_callee) + { + basic_block bb = gimple_bb (e->call_stmt); + e->frequency = compute_call_stmt_bb_frequency (current_function_decl, + bb); e->count = bb->count; } } -- cgit v1.2.1