Patchwork [committed] Honza's alias/weakref fix (PR c++/57945)

login
register
mail settings
Submitter Jakub Jelinek
Date Jan. 17, 2014, 2:21 p.m.
Message ID <20140117142159.GH892@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/312088/
State New
Headers show

Comments

Jakub Jelinek - Jan. 17, 2014, 2:21 p.m.
Hi!

I've bootstrapped/regtested on x86_64-linux and i686-linux
following patch from Honza from the PR comment (written a month
ago, acked by Jason a fortnight ago) and committed it to trunk.

2014-01-17  Jan Hubicka  <hubicka@ucw.cz>

	PR c++/57945
	* passes.c (rest_of_decl_compilation): Don't call varpool_finalize_decl
	on decls for which assemble_alias has been called.

2014-01-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/57945
	* c-c++-common/torture/pr57945.c: New test.


	Jakub
Jan Hubicka - Jan. 17, 2014, 3:31 p.m.
> Hi!
> 
> I've bootstrapped/regtested on x86_64-linux and i686-linux
> following patch from Honza from the PR comment (written a month
> ago, acked by Jason a fortnight ago) and committed it to trunk.
> 
> 2014-01-17  Jan Hubicka  <hubicka@ucw.cz>
> 
> 	PR c++/57945
> 	* passes.c (rest_of_decl_compilation): Don't call varpool_finalize_decl
> 	on decls for which assemble_alias has been called.

Thank you!  I definitely need to empty my patch queue (it took me a while
to get a new setup for gcc testing where I can do LTO of bigger apps again)

Honza

Patch

--- gcc/passes.c.jj	2014-01-03 11:41:01.000000000 +0100
+++ gcc/passes.c	2014-01-17 11:51:15.767231295 +0100
@@ -187,6 +187,8 @@  rest_of_decl_compilation (tree decl,
 			  int top_level,
 			  int at_end)
 {
+  bool finalize = true;
+
   /* We deferred calling assemble_alias so that we could collect
      other attributes such as visibility.  Emit the alias now.  */
   if (!in_lto_p)
@@ -203,6 +205,7 @@  rest_of_decl_compilation (tree decl,
 	DECL_EXTERNAL (decl) = 0;
 	TREE_STATIC (decl) = 1;
 	assemble_alias (decl, alias);
+	finalize = false;
       }
   }
 
@@ -234,7 +237,7 @@  rest_of_decl_compilation (tree decl,
 	     rebuild it.  */
 	  if (in_lto_p && !at_end)
 	    ;
-	  else if (TREE_CODE (decl) != FUNCTION_DECL)
+	  else if (finalize && TREE_CODE (decl) != FUNCTION_DECL)
 	    varpool_finalize_decl (decl);
 	}
 
--- gcc/testsuite/c-c++-common/torture/pr57945.c.jj	2014-01-17 11:52:02.384990286 +0100
+++ gcc/testsuite/c-c++-common/torture/pr57945.c	2014-01-17 11:50:03.000000000 +0100
@@ -0,0 +1,11 @@ 
+/* PR c++/57945 */
+/* { dg-do compile } */
+
+extern int j;
+static int i __attribute__((weakref("j")));
+
+int
+foo (void)
+{
+  return &i ? i : 0;
+}