From d402c33dc1fa4ea0a9f133efdc18ae43b4b4c916 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Mon, 28 Jun 2010 02:10:34 +0200 Subject: [PATCH] re PR middle-end/44671 (Partial inlining breaks C++) PR middle-end/44671 PR middle-end/44686 * tree.c (build_function_decl_skip_args): Clear DECL_BUILT_IN on signature change. * ipa-split.c (split_function): Always clear DECL_BUILT_IN. * ipa-prop.c (ipa_modify_formal_parameters): Likewise. * gcc.c-torture/pr44686.c: New file. From-SVN: r161476 --- gcc/ChangeLog | 9 +++++++++ gcc/ipa-prop.c | 7 +++++++ gcc/ipa-split.c | 10 +++++++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/compile/pr44686.c | 7 +++++++ gcc/tree.c | 7 +++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr44686.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4a1fe90f44d4..d53ba696e7ed 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-06-27 Jan Hubicka + + PR middle-end/44671 + PR middle-end/44686 + * tree.c (build_function_decl_skip_args): Clear DECL_BUILT_IN on signature + change. + * ipa-split.c (split_function): Always clear DECL_BUILT_IN. + * ipa-prop.c (ipa_modify_formal_parameters): Likewise. + 2010-06-27 Anatoly Sokolov * target.h (struct gcc_target): Add register_move_cost field. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 3fd284bff7ad..997f8ec96126 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -2087,6 +2087,13 @@ ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments, DECL_VINDEX (fndecl) = NULL_TREE; } + /* When signature changes, we need to clear builtin info. */ + if (DECL_BUILT_IN (fndecl)) + { + DECL_BUILT_IN_CLASS (fndecl) = NOT_BUILT_IN; + DECL_FUNCTION_CODE (fndecl) = (enum built_in_function) 0; + } + /* This is a new type, not a copy of an old type. Need to reassociate variants. We can handle everything except the main variant lazily. */ t = TYPE_MAIN_VARIANT (orig_type); diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index 1216b0f2c61e..ccc89c431c35 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -277,7 +277,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars, } /* FIXME: we currently can pass only SSA function parameters to the split - arguments. Once parm_adjustment infrastructure is supported by clonning, + arguments. Once parm_adjustment infrastructure is supported by cloning, we can pass more than that. */ if (num_args != bitmap_count_bits (current->ssa_names_to_pass)) { @@ -843,6 +843,14 @@ split_function (struct split_point *split_point) args_to_skip, split_point->split_bbs, split_point->entry_bb, "_part"); + /* For usual cloning it is enough to clear builtin only when signature + changes. For partial inlining we however can not expect the part + of builtin implementation to have same semantic as the whole. */ + if (DECL_BUILT_IN (node->decl)) + { + DECL_BUILT_IN_CLASS (node->decl) = NOT_BUILT_IN; + DECL_FUNCTION_CODE (node->decl) = (enum built_in_function) 0; + } cgraph_node_remove_callees (cgraph_node (current_function_decl)); if (!split_part_return_p) TREE_THIS_VOLATILE (node->decl) = 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 75a47a22a7f4..be888c890685 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-06-27 Jan Hubicka + + * gcc.c-torture/compile/pr44686.c: New file. + 2010-06-27 Richard Guenther PR tree-optimization/44683 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44686.c b/gcc/testsuite/gcc.c-torture/compile/pr44686.c new file mode 100644 index 000000000000..eacd83d31308 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44686.c @@ -0,0 +1,7 @@ +/* { dg-options "-O2 -fipa-pta -fprofile-generate" } */ +void * +memcpy (void *a, const void *b, __SIZE_TYPE__ len) +{ + if (a == b) + __builtin_abort (); +} diff --git a/gcc/tree.c b/gcc/tree.c index a02ac395a336..5e7de012e2ab 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7303,6 +7303,13 @@ build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip) we expect first argument to be THIS pointer. */ if (bitmap_bit_p (args_to_skip, 0)) DECL_VINDEX (new_decl) = NULL_TREE; + + /* When signature changes, we need to clear builtin info. */ + if (DECL_BUILT_IN (new_decl) && !bitmap_empty_p (args_to_skip)) + { + DECL_BUILT_IN_CLASS (new_decl) = NOT_BUILT_IN; + DECL_FUNCTION_CODE (new_decl) = (enum built_in_function) 0; + } return new_decl; }