https://gcc.gnu.org/g:f77f4797010736d9fea7b313b52267d643ebcff7

commit r16-5264-gf77f4797010736d9fea7b313b52267d643ebcff7
Author: zhaozhou <[email protected]>
Date:   Mon Nov 10 15:38:26 2025 +0800

    LoongArch: Fix issue where data marked as GTY is cleaned up by ggc.
    
    As for GGC(GCC Garbage Collection), it's use gengtype tool to scan all
    source files contain the GTY mark, and generate gt-*.h files. GGC
    traversal these file to find gt_root node and marks these objects that
    directly or indirectly reference this node as active, then clean up
    unmarked object's memory.
    
    For the loongarch-builtins.cc file, it is necessary to add
    target_gtfiles in config.gcc to generate gt-loongarch-builtins.h, and
    include this header file in the .cc file, prevented the data marked
    with GTY in this `.cc` file cleaned up by ggc.
    
    gcc/ChangeLog:
    
            * config.gcc: Add target_gtfiles.
            * config/loongarch/loongarch-builtins.cc: Add header file.

Diff:
---
 gcc/config.gcc                             | 1 +
 gcc/config/loongarch/loongarch-builtins.cc | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index d2770ea556b2..fa3ce390f700 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -502,6 +502,7 @@ loongarch*-*-*)
        extra_headers="larchintrin.h lsxintrin.h lasxintrin.h"
        extra_objs="loongarch-c.o loongarch-builtins.o loongarch-cpu.o 
loongarch-opts.o loongarch-def.o loongarch-evolution.o loongarch-target-attr.o"
        extra_gcc_objs="loongarch-driver.o loongarch-cpu.o loongarch-opts.o 
loongarch-def.o"
+       target_gtfiles="\$(srcdir)/config/loongarch/loongarch-builtins.cc"
        extra_options="${extra_options} g.opt fused-madd.opt"
        ;;
 nds32*)
diff --git a/gcc/config/loongarch/loongarch-builtins.cc 
b/gcc/config/loongarch/loongarch-builtins.cc
index 312d87626a4b..6c914c07d299 100644
--- a/gcc/config/loongarch/loongarch-builtins.cc
+++ b/gcc/config/loongarch/loongarch-builtins.cc
@@ -3259,3 +3259,5 @@ loongarch_build_builtin_va_list (void)
 {
   return ptr_type_node;
 }
+
+#include "gt-loongarch-builtins.h"

Reply via email to