public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801)
@ 2010-06-29 19:25 Jakub Jelinek
  2010-06-29 20:03 ` Diego Novillo
  2010-06-30  6:23 ` Jan Hubicka
  0 siblings, 2 replies; 5+ messages in thread
From: Jakub Jelinek @ 2010-06-29 19:25 UTC (permalink / raw)
  To: Richard Guenther, Jan Hubicka; +Cc: gcc-patches

Hi!

When a fndecl is DECL_ONE_ONLY and has DECL_SECTION_NAME already set (e.g.
because of emitting associated thunks), its virtual clones which are not
DECL_ONE_ONLY definitely must not reuse its section, because that results in
section conflicts.  For non-comdat functions e.g. put by user into some
special section I think we can just reuse that section.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
trunk?

2010-06-29  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/43801
	* cgraph.c (cgraph_create_virtual_clone): Clear DECL_SECTION_NAME
	if old_decl was DECL_ONE_ONLY.

	* g++.dg/torture/pr43801.C: New test.

--- gcc/cgraph.c.jj	2010-06-28 15:36:30.000000000 +0200
+++ gcc/cgraph.c	2010-06-29 18:05:36.000000000 +0200
@@ -2217,6 +2217,8 @@ cgraph_create_virtual_clone (struct cgra
      ??? We cannot use COMDAT linkage because there is no
      ABI support for this.  */
   DECL_EXTERNAL (new_node->decl) = 0;
+  if (DECL_ONE_ONLY (old_decl))
+    DECL_SECTION_NAME (new_node->decl) = NULL;
   DECL_COMDAT_GROUP (new_node->decl) = 0;
   TREE_PUBLIC (new_node->decl) = 0;
   DECL_COMDAT (new_node->decl) = 0;
--- gcc/testsuite/g++.dg/torture/pr43801.C.jj	2010-06-29 18:09:32.000000000 +0200
+++ gcc/testsuite/g++.dg/torture/pr43801.C	2010-06-29 18:10:34.000000000 +0200
@@ -0,0 +1,22 @@
+// PR tree-optimization/43801
+// { dg-do compile }
+// { dg-options "-fipa-cp -fipa-cp-clone" }
+
+struct A
+{
+  virtual void f (int);
+};
+struct B : virtual A
+{
+  virtual void f (int i) { if (i) A::f(0); }
+};
+struct C : virtual B
+{
+  virtual void f (int) { B::f(0); }
+};
+
+void
+foo ()
+{
+  C ();
+}

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone  (PR tree-optimization/43801)
  2010-06-29 19:25 [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801) Jakub Jelinek
@ 2010-06-29 20:03 ` Diego Novillo
  2010-06-30  6:23 ` Jan Hubicka
  1 sibling, 0 replies; 5+ messages in thread
From: Diego Novillo @ 2010-06-29 20:03 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Guenther, Jan Hubicka, gcc-patches

On Tue, Jun 29, 2010 at 14:54, Jakub Jelinek <jakub@redhat.com> wrote:

> 2010-06-29  Jakub Jelinek  <jakub@redhat.com>
>
>        PR tree-optimization/43801
>        * cgraph.c (cgraph_create_virtual_clone): Clear DECL_SECTION_NAME
>        if old_decl was DECL_ONE_ONLY.
>
>        * g++.dg/torture/pr43801.C: New test.

OK.


Diego.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801)
  2010-06-29 19:25 [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801) Jakub Jelinek
  2010-06-29 20:03 ` Diego Novillo
@ 2010-06-30  6:23 ` Jan Hubicka
  2010-06-30  8:52   ` Jakub Jelinek
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Hubicka @ 2010-06-30  6:23 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Guenther, Jan Hubicka, gcc-patches

> Hi!
> 
> When a fndecl is DECL_ONE_ONLY and has DECL_SECTION_NAME already set (e.g.
> because of emitting associated thunks), its virtual clones which are not
> DECL_ONE_ONLY definitely must not reuse its section, because that results in
> section conflicts.  For non-comdat functions e.g. put by user into some
> special section I think we can just reuse that section.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
> trunk?
> 
> 2010-06-29  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/43801
> 	* cgraph.c (cgraph_create_virtual_clone): Clear DECL_SECTION_NAME
> 	if old_decl was DECL_ONE_ONLY.

Don't we want to do this in make_decl_local?

Honza

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801)
  2010-06-30  6:23 ` Jan Hubicka
@ 2010-06-30  8:52   ` Jakub Jelinek
  2010-06-30 11:59     ` Jan Hubicka
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2010-06-30  8:52 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Richard Guenther, Jan Hubicka, gcc-patches

On Wed, Jun 30, 2010 at 04:12:55AM +0200, Jan Hubicka wrote:
> > When a fndecl is DECL_ONE_ONLY and has DECL_SECTION_NAME already set (e.g.
> > because of emitting associated thunks), its virtual clones which are not
> > DECL_ONE_ONLY definitely must not reuse its section, because that results in
> > section conflicts.  For non-comdat functions e.g. put by user into some
> > special section I think we can just reuse that section.
> > 
> > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
> > trunk?
> > 
> > 2010-06-29  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	PR tree-optimization/43801
> > 	* cgraph.c (cgraph_create_virtual_clone): Clear DECL_SECTION_NAME
> > 	if old_decl was DECL_ONE_ONLY.
> 
> Don't we want to do this in make_decl_local?

make_decl_local doesn't work on a copy, so if DECL_SECTION_NAME has been
assigned for it, I'd say it is too late to try to make it !DECL_ONE_ONLY
(e.g. associated thunks had to be emitted).
But perhaps it won't hurt to do that anyway.

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801)
  2010-06-30  8:52   ` Jakub Jelinek
@ 2010-06-30 11:59     ` Jan Hubicka
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Hubicka @ 2010-06-30 11:59 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jan Hubicka, Richard Guenther, Jan Hubicka, gcc-patches

> On Wed, Jun 30, 2010 at 04:12:55AM +0200, Jan Hubicka wrote:
> > > When a fndecl is DECL_ONE_ONLY and has DECL_SECTION_NAME already set (e.g.
> > > because of emitting associated thunks), its virtual clones which are not
> > > DECL_ONE_ONLY definitely must not reuse its section, because that results in
> > > section conflicts.  For non-comdat functions e.g. put by user into some
> > > special section I think we can just reuse that section.
> > > 
> > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
> > > trunk?
> > > 
> > > 2010-06-29  Jakub Jelinek  <jakub@redhat.com>
> > > 
> > > 	PR tree-optimization/43801
> > > 	* cgraph.c (cgraph_create_virtual_clone): Clear DECL_SECTION_NAME
> > > 	if old_decl was DECL_ONE_ONLY.
> > 
> > Don't we want to do this in make_decl_local?
> 
> make_decl_local doesn't work on a copy, so if DECL_SECTION_NAME has been
> assigned for it, I'd say it is too late to try to make it !DECL_ONE_ONLY
> (e.g. associated thunks had to be emitted).
> But perhaps it won't hurt to do that anyway.

It is given a copy via cgraph_function_versioning

Honza
> 
> 	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-30 10:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-29 19:25 [PATCH] Clear DECL_SECTION_NAME during cgraph_create_virtual_clone (PR tree-optimization/43801) Jakub Jelinek
2010-06-29 20:03 ` Diego Novillo
2010-06-30  6:23 ` Jan Hubicka
2010-06-30  8:52   ` Jakub Jelinek
2010-06-30 11:59     ` Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).