re PR lto/47924 (Missed optimization with LTO)
authorRichard Guenther <rguenther@suse.de>
Tue, 1 Mar 2011 09:46:19 +0000 (09:46 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 1 Mar 2011 09:46:19 +0000 (09:46 +0000)
2011-03-01  Richard Guenther  <rguenther@suse.de>

PR lto/47924
* lto-streamer.c (lto_record_common_node): Also register
the canonical type.

* gcc.dg/lto/pr47924_0.c: New testcase.

From-SVN: r170589

gcc/ChangeLog
gcc/lto-streamer.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr47924_0.c [new file with mode: 0644]

index 5d567fb498ac5e45997f3f06818885065f7d82d8..79487c18b0c16b02cb53627b123f461052465ff4 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-01  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/47924
+       * lto-streamer.c (lto_record_common_node): Also register
+       the canonical type.
+
 2011-03-01  Richard Guenther  <rguenther@suse.de>
 
        PR lto/46911
index dba9d2d5dd7cbd3cc9789d157c1a36f403f738c2..67132ef1dff9c1bad41916f64e4c871998cf9c64 100644 (file)
@@ -527,7 +527,9 @@ lto_record_common_node (tree *nodep, VEC(tree, heap) **common_nodes,
         are set by the middle-end.  */
       if (in_lto_p)
        TYPE_CANONICAL (node) = NULL_TREE;
-      *nodep = node = gimple_register_type (node);
+      node = gimple_register_type (node);
+      TYPE_CANONICAL (node) = gimple_register_canonical_type (node);
+      *nodep = node;
     }
 
   /* Return if node is already seen.  */
index 65e0db406bf2f8f30e7e31294af7d17136093497..d5e79f82f2e887fb17ac290c697690cfd2c5af39 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-01  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/47924
+       * gcc.dg/lto/pr47924_0.c: New testcase.
+
 2011-03-01  Richard Guenther  <rguenther@suse.de>
 
        PR lto/46911
diff --git a/gcc/testsuite/gcc.dg/lto/pr47924_0.c b/gcc/testsuite/gcc.dg/lto/pr47924_0.c
new file mode 100644 (file)
index 0000000..f7fdb44
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O2 -flto}} } */
+
+extern void link_error (void);
+short *p __attribute__((used));
+int i __attribute__((used));
+
+int main()
+{
+  if (i == 0)
+    return;
+
+  *p = 0;
+
+  if (i == 0)
+    link_error ();
+
+  return 0;
+}