Hi,
This patch implements the TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES for the
arm backend to remove the 'cmse_nonsecure_entry' attribute from cmse.
Bootstrapped the series on x86_64 and built arm-none-eabi, running the
cmse testsuite for armv8-m.main and armv8-m.base.
Is this OK for trunk?
Cheers,
Andre
gcc/ChangeLog:
2019-10-08 Andre Vieira <andre.simoesdiasvie...@arm.com>
* config/arm/arm.c (TARGET_SANITIZE_CLONE_ATTRIBUTES): Define.
(arm_sanitize_clone_attributes): New.
gcc/testsuite/ChangeLog:
2019-10-08 Andre Vieira <andre.simoesdiasvie...@arm.com>
* gcc.target/arm/cmse/ipa-clone.c: New test.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 9f0975dc0710626ef46abecaa3a205e993821118..173172bd28303469faded6b7a84a0b353b62de18 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -811,6 +811,9 @@ static const struct attribute_spec arm_attribute_table[] =
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT arm_constant_alignment
+
+#undef TARGET_SANITIZE_CLONE_ATTRIBUTES
+#define TARGET_SANITIZE_CLONE_ATTRIBUTES arm_sanitize_clone_attributes
/* Obstack for minipool constant handling. */
static struct obstack minipool_obstack;
@@ -31999,6 +32002,15 @@ arm_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return align;
}
+static void
+arm_sanitize_clone_attributes (struct cgraph_node * node)
+{
+ tree attrs = DECL_ATTRIBUTES (node->decl);
+ if (lookup_attribute ("cmse_nonsecure_entry", attrs))
+ attrs = remove_attribute ("cmse_nonsecure_entry", attrs);
+ DECL_ATTRIBUTES (node->decl) = attrs;
+}
+
/* Emit a speculation barrier on target architectures that do not have
DSB/ISB directly. Such systems probably don't need a barrier
themselves, but if the code is ever run on a later architecture, it
diff --git a/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c b/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c
new file mode 100644
index 0000000000000000000000000000000000000000..6ab4c34f7499f9615b5d44c633bb5f9d69e88d39
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/cmse/ipa-clone.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-mcmse" } */
+/* { dg-additional-options "-Ofast" } */
+
+#include <arm_cmse.h>
+
+int __attribute__ ((cmse_nonsecure_entry))
+foo (int a)
+{
+ return 1;
+}
+
+int __attribute__ ((cmse_nonsecure_entry))
+bar (int a)
+{
+ return 1;
+}
+
+int main (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler "foo.constprop.0:" } } */
+/* { dg-final { scan-assembler-not "__acle_se_foo.constprop.0:" } } */
+/* { dg-final { scan-assembler "foo:" } } */
+/* { dg-final { scan-assembler "__acle_se_foo:" } } */
+