summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjiez <jiez@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-23 14:47:46 +0000
committerjiez <jiez@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-23 14:47:46 +0000
commitcd28ae7a10d29bf904d6fcdc55ff5233495ebb6e (patch)
treeb7192056c818495d64ebed95b109b7adcbf4d7e8 /gcc
parent6c359b3cc2eef224fc0af22432d32736b62eb0ce (diff)
downloadgcc-cd28ae7a10d29bf904d6fcdc55ff5233495ebb6e.tar.gz
PR target/44290
* attribs.c (decl_attributes): Insert "noinline" and "noclone" if "naked". * tree-sra.c (ipa_sra_preliminary_function_checks): Return false if ! tree_versionable_function_p. testsuite/ PR target/44290 * gcc.dg/pr44290-1.c: New test. * gcc.dg/pr44290-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162466 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/attribs.c13
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/pr44290-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/pr44290-2.c24
-rw-r--r--gcc/tree-sra.c7
6 files changed, 76 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4873ccdbbd8..adc38f49d2e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-23 Jie Zhang <jie@codesourcery.com>
+
+ PR target/44290
+ * attribs.c (decl_attributes): Insert "noinline" and "noclone"
+ if "naked".
+ * tree-sra.c (ipa_sra_preliminary_function_checks): Return
+ false if ! tree_versionable_function_p.
+
2010-07-23 Nathan Froyd <froydnj@codesourcery.com>
* builtins.def (BUILT_IN_ARGS_INFO): Remove.
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 0d7c13218b5..d8daa6f5ed6 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -276,6 +276,19 @@ decl_attributes (tree *node, tree attributes, int flags)
TREE_VALUE (cur_attr) = chainon (opts, TREE_VALUE (cur_attr));
}
+ /* A "naked" function attribute implies "noinline" and "noclone" for
+ those targets that support it. */
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ && lookup_attribute_spec (get_identifier ("naked"))
+ && lookup_attribute ("naked", attributes) != NULL)
+ {
+ if (lookup_attribute ("noinline", attributes) == NULL)
+ attributes = tree_cons (get_identifier ("noinline"), NULL, attributes);
+
+ if (lookup_attribute ("noclone", attributes) == NULL)
+ attributes = tree_cons (get_identifier ("noclone"), NULL, attributes);
+ }
+
targetm.insert_attributes (*node, &attributes);
for (a = attributes; a; a = TREE_CHAIN (a))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8acb4b22dab..35923e20876 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-23 Jie Zhang <jie@codesourcery.com>
+
+ PR target/44290
+ * gcc.dg/pr44290-1.c: New test.
+ * gcc.dg/pr44290-2.c: New test.
+
2010-07-23 Jason Merrill <jason@redhat.com>
PR c++/45008
diff --git a/gcc/testsuite/gcc.dg/pr44290-1.c b/gcc/testsuite/gcc.dg/pr44290-1.c
new file mode 100644
index 00000000000..071a2710425
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr44290-1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target arm*-*-* avr-*-* mcore-*-* rx-*-* spu-*-* } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+static void __attribute__((naked))
+foo(void *from, void *to)
+{
+ asm volatile("dummy"::"r"(from), "r"(to));
+}
+
+unsigned int fie[2];
+
+void fum(void *to)
+{
+ foo(fie, to);
+}
+
+/* { dg-final { scan-tree-dump "foo \\\(void \\\* from, void \\\* to\\\)" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/pr44290-2.c b/gcc/testsuite/gcc.dg/pr44290-2.c
new file mode 100644
index 00000000000..1951a519dfc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr44290-2.c
@@ -0,0 +1,24 @@
+/* { dg-do compile { target arm*-*-* avr-*-* mcore-*-* rx-*-* spu-*-* } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+static unsigned long __attribute__((naked))
+foo (unsigned long base)
+{
+ asm volatile ("dummy");
+}
+unsigned long
+bar (void)
+{
+ static int start, set;
+
+ if (!set)
+ {
+ set = 1;
+ start = foo (0);
+ }
+
+ return foo (start);
+}
+
+/* { dg-final { scan-tree-dump "foo \\\(long unsigned int base\\\)" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 2ac6458e0f5..2bd9f97e1de 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4301,6 +4301,13 @@ modify_function (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
static bool
ipa_sra_preliminary_function_checks (struct cgraph_node *node)
{
+ if (!tree_versionable_function_p (current_function_decl))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Function isn't allowed to be versioned.\n");
+ return false;
+ }
+
if (!cgraph_node_can_be_local_p (node))
{
if (dump_file)