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/cp/optimize.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 9d4a8c5f8e4..c9d6cebb817 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "tree-dump.h" #include "gimple.h" +#include "tree-iterator.h" /* Prototypes. */ @@ -81,10 +82,7 @@ static void clone_body (tree clone, tree fn, void *arg_map) { copy_body_data id; - gimple_seq new_body; - - /* FN must already be in GIMPLE form. */ - gcc_assert (gimple_body (fn)); + tree stmts; /* Clone the body, as if we were making an inline call. But, remap the parameters in the callee to the parameters of caller. */ @@ -103,9 +101,9 @@ clone_body (tree clone, tree fn, void *arg_map) /* We're not inside any EH region. */ id.eh_region = -1; - /* Actually copy the body. */ - new_body = remap_gimple_seq (gimple_body (fn), &id); - gimple_set_body (clone, new_body); + stmts = DECL_SAVED_TREE (fn); + walk_tree (&stmts, copy_tree_body_r, &id, NULL); + append_to_statement_list_force (stmts, &DECL_SAVED_TREE (clone)); } /* FN is a function that has a complete body. Clone the body as @@ -208,7 +206,8 @@ maybe_clone_body (tree fn) } /* Otherwise, map the VTT parameter to `NULL'. */ else - *pointer_map_insert (decl_map, parm) = null_pointer_node; + *pointer_map_insert (decl_map, parm) + = fold_convert (TREE_TYPE (parm), null_pointer_node); } /* Map other parameters to their equivalents in the cloned function. */ @@ -237,7 +236,6 @@ maybe_clone_body (tree fn) /* Now, expand this function into RTL, if appropriate. */ finish_function (0); BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn); - DECL_SAVED_TREE (clone) = NULL; expand_or_defer_fn (clone); first = false; } -- cgit v1.2.1 From e2932b0d6cab74ef56599547a959a7adc4e8cb47 Mon Sep 17 00:00:00 2001 From: carrot Date: Sun, 13 Sep 2009 15:06:47 +0000 Subject: * cp/optimize.c (build_delete_destructor_body): New function. (maybe_clone_body): Call build_delete_destructor_body for deleting destructor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151673 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 161 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 54 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index c9d6cebb817..abd38f8666c 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -1,5 +1,5 @@ /* Perform optimizations on tree structure. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. Written by Mark Michell (mark@codesourcery.com). @@ -106,6 +106,41 @@ clone_body (tree clone, tree fn, void *arg_map) append_to_statement_list_force (stmts, &DECL_SAVED_TREE (clone)); } +/* DELETE_DTOR is a delete destructor whose body will be built. + COMPLETE_DTOR is the corresponding complete destructor. */ + +static void +build_delete_destructor_body (tree delete_dtor, tree complete_dtor) +{ + tree call_dtor, call_delete; + tree parm = DECL_ARGUMENTS (delete_dtor); + tree virtual_size = cxx_sizeof (current_class_type); + + /* Call the corresponding complete destructor. */ + gcc_assert (complete_dtor); + call_dtor = build_cxx_call (complete_dtor, 1, &parm); + add_stmt (call_dtor); + + add_stmt (build_stmt (0, LABEL_EXPR, cdtor_label)); + + /* Call the delete function. */ + call_delete = build_op_delete_call (DELETE_EXPR, current_class_ptr, + virtual_size, + /*global_p=*/false, + /*placement=*/NULL_TREE, + /*alloc_fn=*/NULL_TREE); + add_stmt (call_delete); + + /* Return the address of the object. */ + if (targetm.cxx.cdtor_returns_this ()) + { + tree val = DECL_ARGUMENTS (delete_dtor); + val = build2 (MODIFY_EXPR, TREE_TYPE (val), + DECL_RESULT (delete_dtor), val); + add_stmt (build_stmt (0, RETURN_EXPR, val)); + } +} + /* FN is a function that has a complete body. Clone the body as necessary. Returns nonzero if there's no longer any need to process the main body. */ @@ -114,6 +149,7 @@ bool maybe_clone_body (tree fn) { tree clone; + tree complete_dtor = NULL_TREE; bool first = true; /* We only clone constructors and destructors. */ @@ -124,6 +160,15 @@ maybe_clone_body (tree fn) /* Emit the DWARF1 abstract instance. */ (*debug_hooks->deferred_inline_function) (fn); + /* Look for the complete destructor which may be used to build the + delete destructor. */ + FOR_EACH_CLONE (clone, fn) + if (DECL_NAME (clone) == complete_dtor_identifier) + { + complete_dtor = clone; + break; + } + /* We know that any clones immediately follow FN in the TYPE_METHODS list. */ push_to_top_level (); @@ -176,59 +221,67 @@ maybe_clone_body (tree fn) /* Start processing the function. */ start_preparsed_function (clone, NULL_TREE, SF_PRE_PARSED); - /* Remap the parameters. */ - decl_map = pointer_map_create (); - for (parmno = 0, - parm = DECL_ARGUMENTS (fn), - clone_parm = DECL_ARGUMENTS (clone); - parm; - ++parmno, - parm = TREE_CHAIN (parm)) - { - /* Map the in-charge parameter to an appropriate constant. */ - if (DECL_HAS_IN_CHARGE_PARM_P (fn) && parmno == 1) - { - tree in_charge; - in_charge = in_charge_arg_for_name (DECL_NAME (clone)); - *pointer_map_insert (decl_map, parm) = in_charge; - } - else if (DECL_ARTIFICIAL (parm) - && DECL_NAME (parm) == vtt_parm_identifier) - { - /* For a subobject constructor or destructor, the next - argument is the VTT parameter. Remap the VTT_PARM - from the CLONE to this parameter. */ - if (DECL_HAS_VTT_PARM_P (clone)) - { - DECL_ABSTRACT_ORIGIN (clone_parm) = parm; - *pointer_map_insert (decl_map, parm) = clone_parm; - clone_parm = TREE_CHAIN (clone_parm); - } - /* Otherwise, map the VTT parameter to `NULL'. */ - else - *pointer_map_insert (decl_map, parm) - = fold_convert (TREE_TYPE (parm), null_pointer_node); - } - /* Map other parameters to their equivalents in the cloned - function. */ - else - { - *pointer_map_insert (decl_map, parm) = clone_parm; - clone_parm = TREE_CHAIN (clone_parm); - } - } - - if (targetm.cxx.cdtor_returns_this ()) - { - parm = DECL_RESULT (fn); - clone_parm = DECL_RESULT (clone); - *pointer_map_insert (decl_map, parm) = clone_parm; - } - /* Clone the body. */ - clone_body (clone, fn, decl_map); - - /* Clean up. */ - pointer_map_destroy (decl_map); + /* Build the delete destructor by calling complete destructor + and delete function. */ + if (DECL_NAME (clone) == deleting_dtor_identifier) + build_delete_destructor_body (clone, complete_dtor); + else + { + /* Remap the parameters. */ + decl_map = pointer_map_create (); + for (parmno = 0, + parm = DECL_ARGUMENTS (fn), + clone_parm = DECL_ARGUMENTS (clone); + parm; + ++parmno, + parm = TREE_CHAIN (parm)) + { + /* Map the in-charge parameter to an appropriate constant. */ + if (DECL_HAS_IN_CHARGE_PARM_P (fn) && parmno == 1) + { + tree in_charge; + in_charge = in_charge_arg_for_name (DECL_NAME (clone)); + *pointer_map_insert (decl_map, parm) = in_charge; + } + else if (DECL_ARTIFICIAL (parm) + && DECL_NAME (parm) == vtt_parm_identifier) + { + /* For a subobject constructor or destructor, the next + argument is the VTT parameter. Remap the VTT_PARM + from the CLONE to this parameter. */ + if (DECL_HAS_VTT_PARM_P (clone)) + { + DECL_ABSTRACT_ORIGIN (clone_parm) = parm; + *pointer_map_insert (decl_map, parm) = clone_parm; + clone_parm = TREE_CHAIN (clone_parm); + } + /* Otherwise, map the VTT parameter to `NULL'. */ + else + *pointer_map_insert (decl_map, parm) + = fold_convert (TREE_TYPE (parm), null_pointer_node); + } + /* Map other parameters to their equivalents in the cloned + function. */ + else + { + *pointer_map_insert (decl_map, parm) = clone_parm; + clone_parm = TREE_CHAIN (clone_parm); + } + } + + if (targetm.cxx.cdtor_returns_this ()) + { + parm = DECL_RESULT (fn); + clone_parm = DECL_RESULT (clone); + *pointer_map_insert (decl_map, parm) = clone_parm; + } + + /* Clone the body. */ + clone_body (clone, fn, decl_map); + + /* Clean up. */ + pointer_map_destroy (decl_map); + } /* The clone can throw iff the original function can throw. */ cp_function_chain->can_throw = !TREE_NOTHROW (fn); -- 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/cp/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index abd38f8666c..58d5b9001d2 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -99,7 +99,7 @@ clone_body (tree clone, tree fn, void *arg_map) id.transform_lang_insert_block = NULL; /* We're not inside any EH region. */ - id.eh_region = -1; + id.eh_lp_nr = 0; stmts = DECL_SAVED_TREE (fn); walk_tree (&stmts, copy_tree_body_r, &id, NULL); -- cgit v1.2.1 From 8514bbf47ce34666037de6d6d2805c98ff70a9e2 Mon Sep 17 00:00:00 2001 From: pinskia Date: Fri, 6 Nov 2009 19:10:07 +0000 Subject: 2009-11-06 Andrew Pinski PR c++/41536 * optimize.c (maybe_clone_body): Copy DECL_ATTRIBUTES and DECL_DISREGARD_INLINE_LIMITS also. 2009-11-06 Andrew Pinski PR c++/41536 * g++.dg/ext/always_inline-5.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153974 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 58d5b9001d2..662bd4a22a3 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -199,6 +199,8 @@ maybe_clone_body (tree fn) DECL_VISIBILITY (clone) = DECL_VISIBILITY (fn); DECL_VISIBILITY_SPECIFIED (clone) = DECL_VISIBILITY_SPECIFIED (fn); DECL_DLLIMPORT_P (clone) = DECL_DLLIMPORT_P (fn); + DECL_ATTRIBUTES (clone) = copy_list (DECL_ATTRIBUTES (fn)); + DECL_DISREGARD_INLINE_LIMITS (clone) = DECL_DISREGARD_INLINE_LIMITS (fn); /* Adjust the parameter names and locations. */ parm = DECL_ARGUMENTS (fn); -- cgit v1.2.1 From ed772161067b3dbee0dbc2ccf93e20e574db2067 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 18 Nov 2009 09:53:52 +0000 Subject: PR c++/3187 * cgraph.h (struct cgraph_node): Add same_body and same_body_alias fields. (cgraph_same_body_alias, cgraph_remove_same_body_alias): New prototypes. * cgraphunit.c (cgraph_expand_function, cgraph_emit_thunks, cgraph_materialize_all_clones): Handle same_body aliases. * cgraph.c (cgraph_allocate_node): New function. (cgraph_create_node): Use it. (cgraph_node_for_decl, cgraph_node, cgraph_get_node, cgraph_node_for_asm, cgraph_remove_node): Handle same_body aliases. (cgraph_same_body_alias, cgraph_remove_same_body_alias): New functions. * lto-cgraph.c (lto_output_node): Stream out same_body aliases. (input_node): Stream in same_body aliases. * lto-symtab.c (lto_cgraph_replace_node): Clear node pointers for same_body aliases. (lto_symtab_merge_cgraph_nodes_1): Handle same_body aliases. * cp-tree.h (expand_or_defer_fn_1): New prototype. * decl2.c (cp_write_global_declarations): Mark as !DECL_EXTERNAL also all same_body aliases. * semantics.c (expand_or_defer_fn): Move most of the function except registering with cgraph to ... (expand_or_defer_fn_1): ... here. New function. * optimize.c: Include cgraph.h. (maybe_clone_body): If in charge parm is not used and both base and complete clones are created and are not comdat, tell cgraph they have the same body. * Make-lang.in (cp/optimize.o): Depend on $(CGRAPH_H). * g++.dg/abi/mangle26.C: Also match *C2* definition. * g++.dg/abi/mangle27.C: Likewise. * g++.dg/abi/mangle28.C: Likewise. * g++.dg/abi/mangle29.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154284 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 56 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 662bd4a22a3..c691f0b6a0b 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-dump.h" #include "gimple.h" #include "tree-iterator.h" +#include "cgraph.h" /* Prototypes. */ @@ -149,8 +150,10 @@ bool maybe_clone_body (tree fn) { tree clone; - tree complete_dtor = NULL_TREE; + tree fns[3]; bool first = true; + bool in_charge_parm_used; + int idx; /* We only clone constructors and destructors. */ if (!DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn) @@ -160,25 +163,40 @@ maybe_clone_body (tree fn) /* Emit the DWARF1 abstract instance. */ (*debug_hooks->deferred_inline_function) (fn); + in_charge_parm_used = CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn)) != NULL; + fns[0] = NULL_TREE; + fns[1] = NULL_TREE; + fns[2] = NULL_TREE; + /* Look for the complete destructor which may be used to build the delete destructor. */ FOR_EACH_CLONE (clone, fn) - if (DECL_NAME (clone) == complete_dtor_identifier) - { - complete_dtor = clone; - break; - } + if (DECL_NAME (clone) == complete_dtor_identifier + || DECL_NAME (clone) == complete_ctor_identifier) + fns[1] = clone; + else if (DECL_NAME (clone) == base_dtor_identifier + || DECL_NAME (clone) == base_ctor_identifier) + fns[0] = clone; + else if (DECL_NAME (clone) == deleting_dtor_identifier) + fns[2] = clone; + else + gcc_unreachable (); /* We know that any clones immediately follow FN in the TYPE_METHODS list. */ push_to_top_level (); - FOR_EACH_CLONE (clone, fn) + for (idx = 0; idx < 3; idx++) { tree parm; tree clone_parm; int parmno; + bool alias = false; struct pointer_map_t *decl_map; + clone = fns[idx]; + if (!clone) + continue; + /* Update CLONE's source position information to match FN's. */ DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn); DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn); @@ -223,12 +241,25 @@ maybe_clone_body (tree fn) /* Start processing the function. */ start_preparsed_function (clone, NULL_TREE, SF_PRE_PARSED); + /* Tell cgraph if both ctors or both dtors are known to have + the same body. */ + if (!in_charge_parm_used + && fns[0] + && idx == 1 + && !flag_use_repository + && DECL_INTERFACE_KNOWN (fns[0]) + && !DECL_ONE_ONLY (fns[0]) + && cgraph_same_body_alias (clone, fns[0])) + alias = true; + /* Build the delete destructor by calling complete destructor and delete function. */ - if (DECL_NAME (clone) == deleting_dtor_identifier) - build_delete_destructor_body (clone, complete_dtor); + if (idx == 2) + build_delete_destructor_body (clone, fns[1]); + else if (alias) + /* No need to populate body. */ ; else - { + { /* Remap the parameters. */ decl_map = pointer_map_create (); for (parmno = 0, @@ -291,7 +322,10 @@ maybe_clone_body (tree fn) /* Now, expand this function into RTL, if appropriate. */ finish_function (0); BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn); - expand_or_defer_fn (clone); + if (alias) + expand_or_defer_fn_1 (clone); + else + expand_or_defer_fn (clone); first = false; } pop_from_top_level (); -- 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/cp/optimize.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index c691f0b6a0b..838a7305a71 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -250,7 +250,10 @@ maybe_clone_body (tree fn) && DECL_INTERFACE_KNOWN (fns[0]) && !DECL_ONE_ONLY (fns[0]) && cgraph_same_body_alias (clone, fns[0])) - alias = true; + { + alias = true; + emit_associated_thunks (clone); + } /* Build the delete destructor by calling complete destructor and delete function. */ -- cgit v1.2.1 From 1d4ef5e7d031e6cca95c774e69f788f744ce92ac Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 1 Dec 2009 20:09:37 +0000 Subject: PR c++/3187 * optimize.c (cdtor_comdat_group): New function. (maybe_clone_body): Also optimize DECL_COMDAT base/complete cdtors and in that case put also the deleting dtor in the same comdat group as base and complete dtor if dtor is virtual. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154880 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 838a7305a71..5a67431cc1f 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -142,6 +142,46 @@ build_delete_destructor_body (tree delete_dtor, tree complete_dtor) } } +/* Return name of comdat group for complete and base ctor (or dtor) + that have the same body. If dtor is virtual, deleting dtor goes + into this comdat group as well. */ + +static tree +cdtor_comdat_group (tree complete, tree base) +{ + tree complete_name = DECL_COMDAT_GROUP (complete); + tree base_name = DECL_COMDAT_GROUP (base); + char *grp_name; + const char *p, *q; + bool diff_seen = false; + size_t idx; + if (complete_name == NULL) + complete_name = cxx_comdat_group (complete); + if (base_name == NULL) + base_name = cxx_comdat_group (base); + gcc_assert (IDENTIFIER_LENGTH (complete_name) + == IDENTIFIER_LENGTH (base_name)); + grp_name = XALLOCAVEC (char, IDENTIFIER_LENGTH (complete_name) + 1); + p = IDENTIFIER_POINTER (complete_name); + q = IDENTIFIER_POINTER (base_name); + for (idx = 0; idx < IDENTIFIER_LENGTH (complete_name); idx++) + if (p[idx] == q[idx]) + grp_name[idx] = p[idx]; + else + { + gcc_assert (!diff_seen + && idx > 0 + && (p[idx - 1] == 'C' || p[idx - 1] == 'D') + && p[idx] == '1' + && q[idx] == '2'); + grp_name[idx] = '5'; + diff_seen = true; + } + grp_name[idx] = '\0'; + gcc_assert (diff_seen); + return get_identifier (grp_name); +} + /* FN is a function that has a complete body. Clone the body as necessary. Returns nonzero if there's no longer any need to process the main body. */ @@ -149,6 +189,7 @@ build_delete_destructor_body (tree delete_dtor, tree complete_dtor) bool maybe_clone_body (tree fn) { + tree comdat_group = NULL_TREE; tree clone; tree fns[3]; bool first = true; @@ -248,10 +289,26 @@ maybe_clone_body (tree fn) && idx == 1 && !flag_use_repository && DECL_INTERFACE_KNOWN (fns[0]) - && !DECL_ONE_ONLY (fns[0]) + && (SUPPORTS_ONE_ONLY || !DECL_WEAK (fns[0])) + && (!DECL_ONE_ONLY (fns[0]) + || (HAVE_COMDAT_GROUP + && DECL_WEAK (fns[0]) + /* Don't optimize synthetized virtual dtors, because then + the deleting and other dtors are emitted when needed + and so it is not certain we would emit both + deleting and complete/base dtors in the comdat group. */ + && (fns[2] == NULL || !DECL_ARTIFICIAL (fn)))) && cgraph_same_body_alias (clone, fns[0])) { alias = true; + if (DECL_ONE_ONLY (fns[0])) + { + /* For comdat base and complete cdtors put them + into the same, *[CD]5* comdat group instead of + *[CD][12]*. */ + comdat_group = cdtor_comdat_group (fns[1], fns[0]); + DECL_COMDAT_GROUP (fns[0]) = comdat_group; + } emit_associated_thunks (clone); } @@ -333,6 +390,15 @@ maybe_clone_body (tree fn) } pop_from_top_level (); + if (comdat_group) + { + DECL_COMDAT_GROUP (fns[1]) = comdat_group; + if (fns[2]) + /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is + virtual, it goes into the same comdat group as well. */ + DECL_COMDAT_GROUP (fns[2]) = comdat_group; + } + /* We don't need to process the original function any further. */ return 1; } -- cgit v1.2.1 From 9358725bfb628705d294484aab5d7bf1bdb5f7d7 Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 3 Dec 2009 08:03:36 +0000 Subject: PR c++/42256 * optimize.c (maybe_clone_body): Call emit_associated_thunks after expand_or_defer_fn_1. * g++.dg/inherit/thunk11.C: New test. * g++.dg/inherit/thunk11.h: New file. * g++.dg/inherit/thunk11-aux.cc: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154937 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 5a67431cc1f..9210a80b71a 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -309,7 +309,6 @@ maybe_clone_body (tree fn) comdat_group = cdtor_comdat_group (fns[1], fns[0]); DECL_COMDAT_GROUP (fns[0]) = comdat_group; } - emit_associated_thunks (clone); } /* Build the delete destructor by calling complete destructor @@ -383,7 +382,10 @@ maybe_clone_body (tree fn) finish_function (0); BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn); if (alias) - expand_or_defer_fn_1 (clone); + { + if (expand_or_defer_fn_1 (clone)) + emit_associated_thunks (clone); + } else expand_or_defer_fn (clone); first = false; -- cgit v1.2.1 From 61c2c7b1e5623d1add0d7281d218f0073dab1943 Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 10 Dec 2009 21:58:49 +0000 Subject: PR c++/42317 * cgraph.h (struct cgraph_node): Add same_comdat_group field. * cgraph.c (cgraph_remove_node): Unchain node from same_comdat_group circular list. (cgraph_node_can_be_local_p): Return false for DECL_COMDAT with node->same_comdat_group. * ipa.c (cgraph_remove_unreachable_nodes): For any reachable node mark all its same_comdat_group nodes as also reachable. (cgraph_externally_visible_p): Return true even if any of same_comdat_group nodes has address taken. * lto-cgraph.c (lto_output_node): Stream out same_comdat_group. (output_cgraph): Ensure other same_comdat_group nodes are also included. (input_node): Stream in same_comdat_group. (input_cgraph_1): Fix up same_comdat_group fields from references to pointers. * cgraphunit.c (cgraph_analyze_functions): Mark all other same_comdat_group nodes as reachable. (cgraph_mark_functions_to_output): For each node->process process also other same_comdat_group nodes. * ipa-inline.c (cgraph_clone_inlined_nodes): Don't reuse nodes with same_comdat_group non-NULL. (cgraph_mark_inline_edge): Likewise. * decl2.c (cp_write_global_declarations): Clear DECL_EXTERNAL also on all other functions in the same comdat group. * optimize.c (maybe_clone_body): Also optimize virtual implicit dtors. For virtual comdat dtors tell cgraph that base and deleting dtor are in the same comdat group. * config/abi/pre/gnu.ver: Don't export certain base dtors that weren't previously exported. * g++.dg/opt/dtor2.C: New test. * g++.dg/opt/dtor2.h: New file. * g++.dg/opt/dtor2-aux.cc: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155143 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 9210a80b71a..325df8ffcd7 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -292,12 +292,7 @@ maybe_clone_body (tree fn) && (SUPPORTS_ONE_ONLY || !DECL_WEAK (fns[0])) && (!DECL_ONE_ONLY (fns[0]) || (HAVE_COMDAT_GROUP - && DECL_WEAK (fns[0]) - /* Don't optimize synthetized virtual dtors, because then - the deleting and other dtors are emitted when needed - and so it is not certain we would emit both - deleting and complete/base dtors in the comdat group. */ - && (fns[2] == NULL || !DECL_ARTIFICIAL (fn)))) + && DECL_WEAK (fns[0]))) && cgraph_same_body_alias (clone, fns[0])) { alias = true; @@ -396,9 +391,18 @@ maybe_clone_body (tree fn) { DECL_COMDAT_GROUP (fns[1]) = comdat_group; if (fns[2]) - /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is - virtual, it goes into the same comdat group as well. */ - DECL_COMDAT_GROUP (fns[2]) = comdat_group; + { + struct cgraph_node *base_dtor_node, *deleting_dtor_node; + /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is + virtual, it goes into the same comdat group as well. */ + DECL_COMDAT_GROUP (fns[2]) = comdat_group; + base_dtor_node = cgraph_node (fns[0]); + deleting_dtor_node = cgraph_node (fns[2]); + gcc_assert (base_dtor_node->same_comdat_group == NULL); + gcc_assert (deleting_dtor_node->same_comdat_group == NULL); + base_dtor_node->same_comdat_group = deleting_dtor_node; + deleting_dtor_node->same_comdat_group = base_dtor_node; + } } /* We don't need to process the original function any further. */ -- cgit v1.2.1 From a2ad849c848413abedcfb1ea1583e6a21601286a Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 3 Feb 2010 00:07:49 +0000 Subject: PR c++/41090 * decl.c (cp_finish_decl): Add local statics to cfun->local_decls. * optimize.c (clone_body): Remap their initializers when making base variants. (maybe_clone_body): Complain if multiple clones aren't safe. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156455 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 325df8ffcd7..5fb769c2c63 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -104,6 +104,21 @@ clone_body (tree clone, tree fn, void *arg_map) stmts = DECL_SAVED_TREE (fn); walk_tree (&stmts, copy_tree_body_r, &id, NULL); + + /* Also remap the initializer of any static variables so that they (in + particular, any label addresses) correspond to the base variant rather + than the abstract one. */ + if (DECL_NAME (clone) == base_dtor_identifier + || DECL_NAME (clone) == base_ctor_identifier) + { + tree decls = DECL_STRUCT_FUNCTION (fn)->local_decls; + for (; decls; decls = TREE_CHAIN (decls)) + { + tree decl = TREE_VALUE (decls); + walk_tree (&DECL_INITIAL (decl), copy_tree_body_r, &id, NULL); + } + } + append_to_statement_list_force (stmts, &DECL_SAVED_TREE (clone)); } @@ -195,6 +210,7 @@ maybe_clone_body (tree fn) bool first = true; bool in_charge_parm_used; int idx; + bool need_alias = false; /* We only clone constructors and destructors. */ if (!DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn) @@ -223,6 +239,11 @@ maybe_clone_body (tree fn) else gcc_unreachable (); + /* Remember if we can't have multiple clones for some reason. We need to + check this before we remap local static initializers in clone_body. */ + if (!tree_versionable_function_p (fn)) + need_alias = true; + /* We know that any clones immediately follow FN in the TYPE_METHODS list. */ push_to_top_level (); @@ -314,6 +335,17 @@ maybe_clone_body (tree fn) /* No need to populate body. */ ; else { + /* If we can't have multiple copies of FN (say, because there's a + static local initialized with the address of a label), we need + to use an alias for the complete variant. */ + if (idx == 1 && need_alias) + { + if (DECL_STRUCT_FUNCTION (fn)->cannot_be_copied_set) + sorry (DECL_STRUCT_FUNCTION (fn)->cannot_be_copied_reason, fn); + else + sorry ("making multiple clones of %qD", fn); + } + /* Remap the parameters. */ decl_map = pointer_map_create (); for (parmno = 0, -- cgit v1.2.1 From 3f9da5596a39ec1c557502bf3f559aaeaf48fc0d Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 30 Apr 2010 11:58:49 +0000 Subject: gcc/ChangeLog: * toplev.c: Include varray.h for statistics dumping. * tree.h: Do not declare varray_head_tag. * tree-into-ssa.c, tree-ssa-uninit.c, tree-phinodes.c, omega.c, regs.h, lto-cgraph.c, tree-ssa-loop-ivopts.c, tree-nomudflap.c, c-objc-common.c, lto-streamer-out.c, tree-ssa-propagate.c, gimple-low.c, c-semantics.c, dwarf2out.c, lto-streamer-in.c, lto-section-in.c, alias.c, tree-if-conv.c, gimplify.c, ggc-zone.c, tree-ssa.c, tree-ssa-loop-prefetch.c, integrate.h, c-gimplify.c, c-common.c, c-common.h, reg-stack.c, basic-block.h, tree-ssa-structalias.c, lto-section-out.c, tree-ssanames.c: Do not include varray.h. * Makefile.in: Update for abovementioned changes. objc/ChangeLog: * objc-act.c: Do not include varray.h. objcp/ChangeLog: * objcp-decl.c: Do not include varray.h. cp/ChangeLog: * optimize.c, parser.c,mangle.c, cp-tree.h: DO not include varray.h. * Make-lang.in: Don't include varray.h dependency in CXX_TREE_H. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158933 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 5fb769c2c63..bad63f55ca8 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -30,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "input.h" #include "integrate.h" #include "toplev.h" -#include "varray.h" #include "params.h" #include "hashtab.h" #include "target.h" -- cgit v1.2.1 From c4b9c21a2470c2d1d1cca1577a802531752ab067 Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 25 May 2010 18:14:23 +0000 Subject: gcc/ChangeLog: * Makefile.in (EXCEPT_H): Fix typo. objc/ChangeLog: * objc-act.h: Do not include gimple.h. * objc-act.c: Do not include rtl.h, expr.h, libfuncs.h, and tm_p.h. Include gimple.h. Explain why except.h has to be included. * objc-lang.c: Do not include diagnostics.h. * Make-lang.in: Update dependencies. objcp/ChangeLog: * objcp-decl.c: Do not include tm.h, rtl.h, expr.h, c-common.h, flags.h, input.h, except.h, output.h, toplev.h, cpplib.h, debug.h, and target.h. * objcp-lang.c: Do not include tm.h, toplev.h, diagnostics.h, and debug.h. Explain why except.h has to be included. * Make-lang.in: Update dependencies. cp/ChangeLog: * cp-tree.h: Do not include splay-tree.h. (struct prtmem_cst): Remove unused field and false comment. * typeck.c: Do not include rtl.h, expr.h, and tm_p.h. * optimize.c: Do not inclde rtl.h, insn-config.h, and integrate.h. * init.c: Do not include rtl.h and expr.h. * class.c: Do not include rtl.h. Include splay-tree.h. (build_clone): Use plain NULL instead of NULL_RTX. * decl.c: Do not include expr.h. Explain why rtl.h has to be included. Include splay-tree.h. * method.c: Do not include rtl.h and expr.h. (use_thunk): Use plain NULL instead of NULL_RTX. * except.c: Do not include rtl.h, expr.h, and libfuncs.h. * tree.c: Do not include rtl.h, insn-config.h, integrate.h, and target.h. Include splay-tree.h. * expr.c: Do not include rtl.h and expr.h. * pt.c: Do not include obstack.h and rtl.h. (tsubst_friend_function): Use plain NULL instead of NULL_RTX. (tsubst_decl): Likewise. (instantiate_decl): Likewise. * semantics.c: Do not include exprt.h and debug.h. Explain why rtl.h has to be included. * decl2.c: Do not include rtl.h and expr.h. Include splay-tree.h. * call.c: Do not include rtl.h and expr.h. * search.c: Do not include obstack.h and rtl.h. * friend.c: Do not include rtl.h and expr.h. * Make-lang.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159839 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/optimize.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index bad63f55ca8..f512570a317 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -25,10 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "tree.h" #include "cp-tree.h" -#include "rtl.h" -#include "insn-config.h" #include "input.h" -#include "integrate.h" #include "toplev.h" #include "params.h" #include "hashtab.h" -- 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/cp/optimize.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index f512570a317..0196eaeb8b1 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -1,6 +1,6 @@ /* Perform optimizations on tree structure. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. Written by Mark Michell (mark@codesourcery.com). This file is part of GCC. @@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "flags.h" #include "langhooks.h" -#include "diagnostic.h" +#include "diagnostic-core.h" #include "tree-dump.h" #include "gimple.h" #include "tree-iterator.h" -- 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/cp/optimize.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 0196eaeb8b1..7ec2034f052 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -107,12 +107,11 @@ clone_body (tree clone, tree fn, void *arg_map) if (DECL_NAME (clone) == base_dtor_identifier || DECL_NAME (clone) == base_ctor_identifier) { - tree decls = DECL_STRUCT_FUNCTION (fn)->local_decls; - for (; decls; decls = TREE_CHAIN (decls)) - { - tree decl = TREE_VALUE (decls); - walk_tree (&DECL_INITIAL (decl), copy_tree_body_r, &id, NULL); - } + unsigned ix; + tree decl; + + FOR_EACH_LOCAL_DECL (DECL_STRUCT_FUNCTION (fn), ix, decl) + walk_tree (&DECL_INITIAL (decl), copy_tree_body_r, &id, NULL); } append_to_statement_list_force (stmts, &DECL_SAVED_TREE (clone)); -- 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/cp/optimize.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gcc/cp/optimize.c') diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 7ec2034f052..302a1332d66 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -282,16 +282,16 @@ maybe_clone_body (tree fn) clone_parm = DECL_ARGUMENTS (clone); /* Update the `this' parameter, which is always first. */ update_cloned_parm (parm, clone_parm, first); - parm = TREE_CHAIN (parm); - clone_parm = TREE_CHAIN (clone_parm); + parm = DECL_CHAIN (parm); + clone_parm = DECL_CHAIN (clone_parm); if (DECL_HAS_IN_CHARGE_PARM_P (fn)) - parm = TREE_CHAIN (parm); + parm = DECL_CHAIN (parm); if (DECL_HAS_VTT_PARM_P (fn)) - parm = TREE_CHAIN (parm); + parm = DECL_CHAIN (parm); if (DECL_HAS_VTT_PARM_P (clone)) - clone_parm = TREE_CHAIN (clone_parm); + clone_parm = DECL_CHAIN (clone_parm); for (; parm; - parm = TREE_CHAIN (parm), clone_parm = TREE_CHAIN (clone_parm)) + parm = DECL_CHAIN (parm), clone_parm = DECL_CHAIN (clone_parm)) /* Update this parameter. */ update_cloned_parm (parm, clone_parm, first); @@ -348,7 +348,7 @@ maybe_clone_body (tree fn) clone_parm = DECL_ARGUMENTS (clone); parm; ++parmno, - parm = TREE_CHAIN (parm)) + parm = DECL_CHAIN (parm)) { /* Map the in-charge parameter to an appropriate constant. */ if (DECL_HAS_IN_CHARGE_PARM_P (fn) && parmno == 1) @@ -367,7 +367,7 @@ maybe_clone_body (tree fn) { DECL_ABSTRACT_ORIGIN (clone_parm) = parm; *pointer_map_insert (decl_map, parm) = clone_parm; - clone_parm = TREE_CHAIN (clone_parm); + clone_parm = DECL_CHAIN (clone_parm); } /* Otherwise, map the VTT parameter to `NULL'. */ else @@ -379,7 +379,7 @@ maybe_clone_body (tree fn) else { *pointer_map_insert (decl_map, parm) = clone_parm; - clone_parm = TREE_CHAIN (clone_parm); + clone_parm = DECL_CHAIN (clone_parm); } } -- cgit v1.2.1