From 5ec7740496a6908b32cd058c0520a2bd5a689bb5 Mon Sep 17 00:00:00 2001 From: Andrew Pinski <quic_apinski@quicinc.com> Date: Wed, 28 Feb 2024 22:39:32 -0800 Subject: [PATCH] aarch64: Fix memtag builtins vs GC [PR108174] The memtag builtins were being GC'ed away so we end up with a crash sometimes (maybe even wrong code). This fixes that issue by adding GTY on the variable/struct aarch64_memtag_builtin_data. Committed as obvious after a build/test for aarch64-linux-gnu. PR target/108174 gcc/ChangeLog: * config/aarch64/aarch64-builtins.cc (aarch64_memtag_builtin_data): Make static and mark with GTY. gcc/testsuite/ChangeLog: * gcc.target/aarch64/acle/memtag_4.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> --- gcc/config/aarch64/aarch64-builtins.cc | 2 +- gcc/testsuite/gcc.target/aarch64/acle/memtag_4.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/memtag_4.c diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc index 277904f6d142..75d21de14011 100644 --- a/gcc/config/aarch64/aarch64-builtins.cc +++ b/gcc/config/aarch64/aarch64-builtins.cc @@ -1840,7 +1840,7 @@ aarch64_init_prefetch_builtin (void) } /* Initialize the memory tagging extension (MTE) builtins. */ -struct +static GTY(()) struct GTY(()) { tree ftype; enum insn_code icode; diff --git a/gcc/testsuite/gcc.target/aarch64/acle/memtag_4.c b/gcc/testsuite/gcc.target/aarch64/acle/memtag_4.c new file mode 100644 index 000000000000..1e209ffc25a8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/memtag_4.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv9-a+memtag --param ggc-min-expand=0 --param ggc-min-heapsize=0" } */ +/* PR target/108174 */ +/* Check to make sure that the builtin functions are not GC'ed away. */ +#include "arm_acle.h" + +void g(void) +{ + const char *c; + __arm_mte_increment_tag(c , 0 ); +} +void h(void) +{ + const char *c; + __arm_mte_increment_tag( c,0); +} -- GitLab