From f0d26d578d94a3fafc81d191d2168ab3517b3f0e Mon Sep 17 00:00:00 2001 From: hubicka Date: Fri, 4 Apr 2014 18:02:31 +0000 Subject: [PATCH] PR ipa/59626 * lto-cgraph.c (input_overwrite_node): Check that partitioning flags are set only during streaming. * ipa.c (process_references, walk_polymorphic_call_targets, symtab_remove_unreachable_nodes): Drop bodies of always inline after early inlining. (symtab_remove_unreachable_nodes): Remove always_inline attribute. * gcc.dg/lto/pr59626_0.c: New testcase. * gcc.dg/lto/pr59626_1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209123 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 10 ++++++++++ gcc/ipa.c | 16 ++++++++++++++-- gcc/lto-cgraph.c | 6 ++++++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/lto/pr59626_0.c | 15 +++++++++++++++ gcc/testsuite/gcc.dg/lto/pr59626_1.c | 4 ++++ 6 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/lto/pr59626_0.c create mode 100644 gcc/testsuite/gcc.dg/lto/pr59626_1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad1d2c15e63..90a787c9a01 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-04-04 Jan Hubicka + + PR ipa/59626 + * lto-cgraph.c (input_overwrite_node): Check that partitioning + flags are set only during streaming. + * ipa.c (process_references, walk_polymorphic_call_targets, + symtab_remove_unreachable_nodes): Drop bodies of always inline + after early inlining. + (symtab_remove_unreachable_nodes): Remove always_inline attribute. + 2014-04-04 Jakub Jelinek Ramana Radhakrishnan diff --git a/gcc/ipa.c b/gcc/ipa.c index 435fff0d4cb..c76687604dd 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -139,7 +139,10 @@ process_references (struct ipa_ref_list *list, if (node->definition && !node->in_other_partition && ((!DECL_EXTERNAL (node->decl) || node->alias) - || (before_inlining_p + || (((before_inlining_p + && (cgraph_state < CGRAPH_STATE_IPA_SSA + || !lookup_attribute ("always_inline", + DECL_ATTRIBUTES (node->decl))))) /* We use variable constructors during late complation for constant folding. Keep references alive so partitioning knows about potential references. */ @@ -191,7 +194,10 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets, /* Prior inlining, keep alive bodies of possible targets for devirtualization. */ if (n->definition - && before_inlining_p) + && (before_inlining_p + && (cgraph_state < CGRAPH_STATE_IPA_SSA + || !lookup_attribute ("always_inline", + DECL_ATTRIBUTES (n->decl))))) pointer_set_insert (reachable, n); /* Even after inlining we want to keep the possible targets in the @@ -491,6 +497,12 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) node->alias = false; node->thunk.thunk_p = false; node->weakref = false; + /* After early inlining we drop always_inline attributes on + bodies of functions that are still referenced (have their + address taken). */ + DECL_ATTRIBUTES (node->decl) + = remove_attribute ("always_inline", + DECL_ATTRIBUTES (node->decl)); if (!node->in_other_partition) node->local.local = false; cgraph_node_remove_callees (node); diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 6206de6d70a..173067f65cf 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -1001,6 +1001,9 @@ input_overwrite_node (struct lto_file_decl_data *file_data, node->thunk.thunk_p = bp_unpack_value (bp, 1); node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution, LDPR_NUM_KNOWN); + gcc_assert (flag_ltrans + || (!node->in_other_partition + && !node->used_from_other_partition)); } /* Return string alias is alias of. */ @@ -1169,6 +1172,9 @@ input_varpool_node (struct lto_file_decl_data *file_data, node->same_comdat_group = (symtab_node *) (intptr_t) ref; node->resolution = streamer_read_enum (ib, ld_plugin_symbol_resolution, LDPR_NUM_KNOWN); + gcc_assert (flag_ltrans + || (!node->in_other_partition + && !node->used_from_other_partition)); return node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 11a0a5e21a7..b073b7f79d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-04-04 Jan Hubicka + + PR ipa/59626 + testcase by Richard Biener + * gcc.dg/lto/pr59626_0.c: New testcase. + * gcc.dg/lto/pr59626_1.c: New testcase. + 2014-04-04 Ramana Radhakrishnan PR debug/60655 diff --git a/gcc/testsuite/gcc.dg/lto/pr59626_0.c b/gcc/testsuite/gcc.dg/lto/pr59626_0.c new file mode 100644 index 00000000000..752982fb506 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr59626_0.c @@ -0,0 +1,15 @@ +/* { dg-lto-do run } */ + +int __atoi (const char *) __asm__("atoi"); +extern inline __attribute__((always_inline,gnu_inline)) +int atoi (const char *x) +{ + return __atoi (x); +} + +int bar (int (*)(const char *)); + +int main() +{ + return bar (atoi); +} diff --git a/gcc/testsuite/gcc.dg/lto/pr59626_1.c b/gcc/testsuite/gcc.dg/lto/pr59626_1.c new file mode 100644 index 00000000000..9b3fa1d2e36 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr59626_1.c @@ -0,0 +1,4 @@ +int bar (int (*fn)(const char *)) +{ + return fn ("0"); +} -- 2.11.4.GIT