diff options
author | Simon Baldwin <simonb@google.com> | 2009-02-20 12:10:59 +0000 |
---|---|---|
committer | Simon Baldwin <simonb@google.com> | 2009-02-20 12:10:59 +0000 |
commit | 84878d92ee763ace6df7636329a2ecf94760b2f0 (patch) | |
tree | dd51cf936b6bcc6599064aaeff8ca5111d694cea /gcc | |
parent | fc1d3d7112bb26dfaea1c234ce6dc276d151fe6f (diff) |
* cgraph.h (cgraph_is_clone_node): New function declaration.
* cgraph.c (cgraph_is_clone_node): Definition.
* ipa-cp.c (ipcp_ltrans_cloning_candidate_p): New function,
applies extra candidate check for ltrans.
(ipcp_cloning_candidate_p): Call it.
* gcc.dg/lto/20090219_0.c: New.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/lto@144319 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog.lto | 8 | ||||
-rw-r--r-- | gcc/cgraph.c | 7 | ||||
-rw-r--r-- | gcc/cgraph.h | 1 | ||||
-rw-r--r-- | gcc/ipa-cp.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog.lto | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/20090219_0.c | 28 |
6 files changed, 80 insertions, 0 deletions
diff --git a/gcc/ChangeLog.lto b/gcc/ChangeLog.lto index b01c6f51689..fef37ad9434 100644 --- a/gcc/ChangeLog.lto +++ b/gcc/ChangeLog.lto @@ -1,3 +1,11 @@ +2009-02-20 Simon Baldwin <simonb@google.com> + + * cgraph.h (cgraph_is_clone_node): New function declaration. + * cgraph.c (cgraph_is_clone_node): Definition. + * ipa-cp.c (ipcp_ltrans_cloning_candidate_p): New function, + applies extra candidate check for ltrans. + (ipcp_cloning_candidate_p): Call it. + 2009-02-19 Diego Novillo <dnovillo@google.com> Revert diff --git a/gcc/cgraph.c b/gcc/cgraph.c index c1d3d37bdf9..18cb97b0cd2 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1422,6 +1422,13 @@ cgraph_clone_input_node (struct cgraph_node *n) return new_node; } +/* Return true if N is a cloned node. */ + +bool +cgraph_is_clone_node (struct cgraph_node *n) +{ + return n->next_clone || n->prev_clone; +} /* Return true if N is an master_clone, (see cgraph_master_clone). */ diff --git a/gcc/cgraph.h b/gcc/cgraph.h index b38cd517de0..9d6bdf65ab8 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -407,6 +407,7 @@ bool cgraph_function_possibly_inlined_p (tree); void cgraph_unnest_node (struct cgraph_node *); enum availability cgraph_function_body_availability (struct cgraph_node *); +bool cgraph_is_clone_node (struct cgraph_node *); bool cgraph_is_master_clone (struct cgraph_node *, bool); struct cgraph_node *cgraph_master_clone (struct cgraph_node *, bool); void cgraph_add_new_function (tree, bool); diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index afeb82b666b..46cd5589362 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -379,6 +379,33 @@ ipcp_print_all_lattices (FILE * f) } } +/* Return true if this NODE may be cloned in ltrans. + + FIXME lto: returns false if any caller of NODE is a clone, described + in http://gcc.gnu.org/ml/gcc/2009-02/msg00297.html; this extra check + should be deleted if the underlying issue is resolved. */ + +static bool +ipcp_ltrans_cloning_candidate_p (struct cgraph_node *node) +{ + struct cgraph_edge *e; + + /* Check callers of this node to see if any is a clone. */ + for (e = node->callers; e; e = e->next_caller) + { + if (cgraph_is_clone_node (e->caller)) + break; + } + if (e) + { + if (dump_file) + fprintf (dump_file, "Not considering %s for cloning; has a clone caller.\n", + cgraph_node_name (node)); + return false; + } + return true; +} + /* Return true if this NODE is viable candidate for cloning. */ static bool ipcp_cloning_candidate_p (struct cgraph_node *node) @@ -395,6 +422,11 @@ ipcp_cloning_candidate_p (struct cgraph_node *node) if (!node->needed || !node->analyzed) return false; + /* If reading ltrans, we want an extra check here. + FIXME lto: see ipcp_ltrans_cloning_candidate_p above for details. */ + if (flag_ltrans && !ipcp_ltrans_cloning_candidate_p (node)) + return false; + if (cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE) { if (dump_file) diff --git a/gcc/testsuite/ChangeLog.lto b/gcc/testsuite/ChangeLog.lto index 20193c0a6fb..7bc7ffca216 100644 --- a/gcc/testsuite/ChangeLog.lto +++ b/gcc/testsuite/ChangeLog.lto @@ -1,3 +1,7 @@ +2009-02-20 Simon Baldwin <simonb@google.com> + + * gcc.dg/lto/20090219_0.c: New. + 2009-02-19 Diego Novillo <dnovillo@google.com> Revert diff --git a/gcc/testsuite/gcc.dg/lto/20090219_0.c b/gcc/testsuite/gcc.dg/lto/20090219_0.c new file mode 100644 index 00000000000..04a34beab05 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090219_0.c @@ -0,0 +1,28 @@ +/* { dg-do link } */ +/* { dg-options "{-O3 -fwhopr -shared}" } */ + +struct Foo { int f1, f2, f3, f4, f5; }; + +int x = 0; +struct Foo *foo; + +inline void Bar(int n){ + foo[x].f1 = 0; + foo[x].f2 = 0; + foo[x].f3 = 0; + foo[x].f4 = 0; + foo[x].f5 = n; +} + +int ei[1]; +inline void Baz(int n) { + if (ei[n] == 1) + Bar (0); + else if (ei[n] == 0) + Bar (1); +} + +void mumble(void) { + for (;;) + Baz (0); +} |