https://gcc.gnu.org/g:a6b7ca00401bafb1e8ac050cc8a926d04f42a1a4
commit r17-6421-ga6b7ca00401bafb1e8ac050cc8a926d04f42a1a4 Author: Christophe Lyon <[email protected]> Date: Mon Nov 16 21:41:15 2026 +0000 arm: Fix PCH restoration of SIMD builtin types [PR128039] The ARM backend initializes its SIMD builtin types before loading a PCH. However, arm_simd_types and arm_fp16_type_node are not registered as GGC roots, so their tree pointers are not properly restored when loading a PCH. This can lead to inconsistent references to the same scalar type, causing an ICE in arm_mve_type_for_scalar_type when including arm_mve.h after loading a PCH. This patch adds the necessary GTY annotations to arm_simd_type_info, arm_simd_types and arm_fp16_type_node, and adds arm-builtins.h to target_gtfiles so that gengtype can process the structure definition. PR target/128039 gcc/ChangeLog: * config.gcc: Add arm-builtins.h to target_gtfiles. * config/arm/arm-builtins.cc (arm_simd_types, arm_fp16_type_node): Declare with GTY annotation. * config/arm/arm-builtins.h (struct arm_simd_type_info): Add GTY annotation. gcc/testsuite/ChangeLog: * gcc.target/arm/pch/arm-pch.exp: New test driver. * gcc.target/arm/pch/pr128039.c: New test. * gcc.target/arm/pch/pr128039.hs: New test. Diff: --- gcc/config.gcc | 2 +- gcc/config/arm/arm-builtins.cc | 2 ++ gcc/config/arm/arm-builtins.h | 2 +- gcc/testsuite/gcc.target/arm/pch/arm-pch.exp | 46 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/arm/pch/pr128039.c | 8 +++++ gcc/testsuite/gcc.target/arm/pch/pr128039.hs | 5 +++ 6 files changed, 63 insertions(+), 2 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index d5fdbd0b8646..91891b67bbb9 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -412,7 +412,7 @@ arm*-*-*) cxx_target_objs="arm-c.o" d_target_objs="arm-d.o" extra_options="${extra_options} arm/arm-tables.opt" - target_gtfiles="\$(srcdir)/config/arm/arm-builtins.cc \$(srcdir)/config/arm/arm-mve-builtins.h \$(srcdir)/config/arm/arm-mve-builtins.cc" + target_gtfiles="\$(srcdir)/config/arm/arm-builtins.cc \$(srcdir)/config/arm/arm-builtins.h \$(srcdir)/config/arm/arm-mve-builtins.h \$(srcdir)/config/arm/arm-mve-builtins.cc" ;; avr-*-*) cpu_type=avr diff --git a/gcc/config/arm/arm-builtins.cc b/gcc/config/arm/arm-builtins.cc index ee5c6041fec7..e9836d2113cb 100644 --- a/gcc/config/arm/arm-builtins.cc +++ b/gcc/config/arm/arm-builtins.cc @@ -942,12 +942,14 @@ const char *arm_scalar_builtin_types[] = { "__simd" #S "_" #T "_t", \ #G "__simd" #S "_" #T "_t", \ NULL_TREE, NULL_TREE, M##mode, qualifier_##Q}, +extern GTY(()) struct arm_simd_type_info arm_simd_types[]; struct arm_simd_type_info arm_simd_types [] = { #include "arm-simd-builtin-types.def" }; #undef ENTRY /* The user-visible __fp16 type. */ +extern GTY(()) tree arm_fp16_type_node; tree arm_fp16_type_node = NULL_TREE; /* Back-end node type for brain float (bfloat) types. */ diff --git a/gcc/config/arm/arm-builtins.h b/gcc/config/arm/arm-builtins.h index 7d4a51582fe8..3cc11c1d8302 100644 --- a/gcc/config/arm/arm-builtins.h +++ b/gcc/config/arm/arm-builtins.h @@ -91,7 +91,7 @@ enum arm_type_qualifiers qualifier_predicate = 0x4000 }; -struct arm_simd_type_info +struct GTY(()) arm_simd_type_info { enum arm_simd_type type; diff --git a/gcc/testsuite/gcc.target/arm/pch/arm-pch.exp b/gcc/testsuite/gcc.target/arm/pch/arm-pch.exp new file mode 100644 index 000000000000..3033468badad --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pch/arm-pch.exp @@ -0,0 +1,46 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. +# Contributed by ARM Ltd. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. */ + +# Exit immediately if this isn't an arm target. +if {![istarget arm*-*-*] } then { + return +} + +# Load support procs. +load_lib gcc-dg.exp +load_lib dg-pch.exp +load_lib torture-options.exp + +# Initialize `dg'. +dg-init +torture-init +set-torture-options $DG_TORTURE_OPTIONS +pch-init + +# Main loop. +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + global torture_without_loops + dg-pch $subdir $test \ + [concat [list {-O0 -g}] $torture_without_loops] ".h" +} + +# All done. +pch-finish +torture-finish +dg-finish diff --git a/gcc/testsuite/gcc.target/arm/pch/pr128039.c b/gcc/testsuite/gcc.target/arm/pch/pr128039.c new file mode 100644 index 000000000000..a98560cc5d71 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pch/pr128039.c @@ -0,0 +1,8 @@ +/* PR target/128039: ICE when including arm_mve.h after a PCH. */ +/* { dg-require-effective-target arm_v8_1m_mve_ok } */ +/* { dg-add-options arm_v8_1m_mve } */ + +#include "pr128039.h" +#include <arm_mve.h> + +int func(int) { return 0; } diff --git a/gcc/testsuite/gcc.target/arm/pch/pr128039.hs b/gcc/testsuite/gcc.target/arm/pch/pr128039.hs new file mode 100644 index 000000000000..662665d0db5d --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pch/pr128039.hs @@ -0,0 +1,5 @@ +/* PR target/128039. */ +/* Empty header file on purpose. */ + +/* { dg-require-effective-target arm_v8_1m_mve_ok } */ +/* { dg-add-options arm_v8_1m_mve } */
