diff mbox series

[2/2,Arm] Implement TARGET_HOOK_SANITIZE_CLONE_ATTRIBUTES to remove cmse_nonsecure_entry

Message ID 5a9d0431-f483-01bb-01d0-949e9badb765@arm.com
State New
Headers show
Series Fix cloning of 'cmse_nonsecure_entry' functions | expand

Commit Message

Andre Vieira (lists) Oct. 8, 2019, 3:20 p.m. UTC
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.simoesdiasvieira@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.simoesdiasvieira@arm.com>

         * gcc.target/arm/cmse/ipa-clone.c: New test.

Comments

Ramana Radhakrishnan Oct. 10, 2019, 11:29 p.m. UTC | #1
On Tue, Oct 8, 2019 at 4:21 PM Andre Vieira (lists)
<andre.simoesdiasvieira@arm.com> wrote:
>
> 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?

Ok if the common bit is approved.  And do watch out for any testsuite
multilib fallout.

Ramana
>
> Cheers,
> Andre
>
> gcc/ChangeLog:
>
> 2019-10-08  Andre Vieira  <andre.simoesdiasvieira@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.simoesdiasvieira@arm.com>
>
>          * gcc.target/arm/cmse/ipa-clone.c: New test.
Andre Vieira (lists) Oct. 15, 2019, 11:14 a.m. UTC | #2
Hi,

Just some minor changes after name changes in the first patch. I'll 
assume this is also OK.

gcc/ChangeLog:
2019-10-15  Andre Vieira  <andre.simoesdiasvieira@arm.com>

         * config/arm/arm.c (TARGET_MODIFY_CLONE_CGRAPH_NODE): Define.
         (arm_modify_clone_cgraph_node): New.

gcc/testsuite/ChangeLog:
2019-10-15  Andre Vieira  <andre.simoesdiasvieira@arm.com>

         * gcc.target/arm/cmse/ipa-clone.c: New test.


On 11/10/2019 00:29, Ramana Radhakrishnan wrote:
> On Tue, Oct 8, 2019 at 4:21 PM Andre Vieira (lists)
> <andre.simoesdiasvieira@arm.com> wrote:
>>
>> 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?
> 
> Ok if the common bit is approved.  And do watch out for any testsuite
> multilib fallout.
> 
> Ramana
>>
>> Cheers,
>> Andre
>>
>> gcc/ChangeLog:
>>
>> 2019-10-08  Andre Vieira  <andre.simoesdiasvieira@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.simoesdiasvieira@arm.com>
>>
>>           * gcc.target/arm/cmse/ipa-clone.c: New test.
diff mbox series

Patch

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:" } } */
+