summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-31 14:26:38 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-31 14:26:38 +0000
commite54aa8a4b85c7f1e8ea0dd233a65c1daa5c816cb (patch)
tree42ff300848a41e6cdbc324d1a275461b455846f8
parent34e283832c924a8e04b2bdb5539a75139f4310c0 (diff)
downloadgcc-e54aa8a4b85c7f1e8ea0dd233a65c1daa5c816cb.tar.gz
2011-10-31 Paul Brook <paul@codesourcery.com>
gcc/ * cgraphunit.c: Don't mark clones as static constructors. gcc/testsuite/ * gcc.dg/constructor-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180700 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/cgraphunit.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/constructor-1.c37
4 files changed, 49 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 198c48862ff..53f8878288d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2011-10-31 Paul Brook <paul@codesourcery.com>
+
+ * cgraphunit.c: Don't mark clones as static constructors.
+
2011-10-31 David Edelsohn <dje.gcc@gmail.com>
* gcc-ar: Do not include stdio.h.
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 25d7561cbdb..83c47ab66fd 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2366,6 +2366,10 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
SET_DECL_RTL (new_decl, NULL);
+ /* When the old decl was a con-/destructor make sure the clone isn't. */
+ DECL_STATIC_CONSTRUCTOR(new_decl) = 0;
+ DECL_STATIC_DESTRUCTOR(new_decl) = 0;
+
/* Create the new version's call-graph node.
and update the edges of the new node. */
new_version_node =
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0828817cee5..a432ab85164 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2011-10-31 Paul Brook <paul@codesourcery.com>
+
+ * gcc.dg/constructor-1.c: New test.
+
2011-10-30 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/50753
diff --git a/gcc/testsuite/gcc.dg/constructor-1.c b/gcc/testsuite/gcc.dg/constructor-1.c
new file mode 100644
index 00000000000..1095a455cfa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/constructor-1.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+/* The ipa-split pass pulls the body of the if(!x) block
+ into a separate function to make foo a better inlining
+ candidate. Make sure this new function isn't also run
+ as a static constructor. */
+
+#include <stdlib.h>
+
+int x, y;
+
+void __attribute__((noinline))
+bar(void)
+{
+ y++;
+}
+
+void __attribute__((constructor))
+foo(void)
+{
+ if (!x)
+ {
+ bar();
+ y++;
+ }
+}
+
+int main()
+{
+ x = 1;
+ foo();
+ foo();
+ if (y != 2)
+ abort();
+ exit(0);
+}