OSDN Git Service

PR lto/46083
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Jan 2011 21:54:33 +0000 (21:54 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Jan 2011 21:54:33 +0000 (21:54 +0000)
* lto-streamer-out.c (pack_ts_function_decl_value_fields): Store
DECL_FINI_PRIORITY.
* lto-streamer-in.c (unpack_ts_function_decl_value_fields):
Restore DECL_FINI_PRIORITY.
* gcc.dg/initpri3.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168642 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d7ffbef..14d5066 100644 (file)
@@ -1,3 +1,11 @@
+2011-01-10  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/46083
+       * lto-streamer-out.c (pack_ts_function_decl_value_fields): Store
+       DECL_FINI_PRIORITY.
+       * lto-streamer-in.c (unpack_ts_function_decl_value_fields):
+       Restore DECL_FINI_PRIORITY.
+
 2011-01-10  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * doc/gimple.texi: Fix quoting of multi-word return values in
index 4fe9cdb..ba48cbb 100644 (file)
@@ -1683,6 +1683,11 @@ unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
   DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
+  if (DECL_STATIC_DESTRUCTOR (expr))
+    {
+       priority_type p = (priority_type) bp_unpack_value (bp, HOST_BITS_PER_SHORT);
+       SET_DECL_FINI_PRIORITY (expr, p);
+    }
 }
 
 
index 781b257..82c2f6f 100644 (file)
@@ -496,6 +496,8 @@ pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
   bp_pack_value (bp, DECL_DISREGARD_INLINE_LIMITS (expr), 1);
   bp_pack_value (bp, DECL_PURE_P (expr), 1);
   bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1);
+  if (DECL_STATIC_DESTRUCTOR (expr))
+    bp_pack_value (bp, DECL_FINI_PRIORITY (expr), HOST_BITS_PER_SHORT);
 }
 
 
index 08241ca..6df0d8e 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-10  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/46083
+       * gcc.dg/initpri3.c: New testcase.
+
 2011-01-10  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR lto/47222
diff --git a/gcc/testsuite/gcc.dg/initpri3.c b/gcc/testsuite/gcc.dg/initpri3.c
new file mode 100644 (file)
index 0000000..1633da0
--- /dev/null
@@ -0,0 +1,64 @@
+/* { dg-do run { target init_priority } } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -O3" } */
+
+extern void abort ();
+
+int i;
+int j;
+
+void c1() __attribute__((constructor (500)));
+void c2() __attribute__((constructor (700)));
+void c3() __attribute__((constructor (600)));
+
+void c1() {
+  if (i++ != 0)
+    abort ();
+}
+
+void c2() {
+  if (i++ != 2)
+    abort ();
+}
+
+void c3() {
+  if (i++ != 1)
+    abort ();
+}
+
+void d1() __attribute__((destructor (500)));
+void d2() __attribute__((destructor (700)));
+void d3() __attribute__((destructor (600)));
+
+void d1() {
+  if (--i != 0)
+    abort ();
+}
+
+void d2() {
+  if (--i != 2)
+    abort ();
+}
+
+void d3() {
+  if (j != 2)
+    abort ();
+  if (--i != 1)
+    abort ();
+}
+
+void cd4() __attribute__((constructor (800), destructor (800)));
+
+void cd4() {
+  if (i != 3)
+    abort ();
+  ++j;
+}
+
+int main () {
+  if (i != 3)
+    return 1;
+  if (j != 1)
+    abort ();
+  return 0;
+}