https://gcc.gnu.org/g:6aa3329b3430c6362ddf51e403d147e0b10d7401

commit r15-7410-g6aa3329b3430c6362ddf51e403d147e0b10d7401
Author: Tobias Burnus <tbur...@baylibre.com>
Date:   Fri Feb 7 13:22:08 2025 +0100

    [gcn] Fix the output amdhsa.version
    
    The amdhsa.version depends on the code object version; while V3 had 1.0,
    V4 has 1.1 and V5 (and V6) have 1.2. GCC used 1.0 but generated since
    a while either V4 or, with -march=gfx...-generic, V6. Now it uses the
    proper version again.
    
    gcc/ChangeLog:
    
            * config/gcn/gcn.cc (gcn_hsa_declare_function_name): Update
            'amdhsa.version' output to match used code version.
            * config/gcn/gen-gcn-device-macros.awk: Add a comment to
            crosslink.

Diff:
---
 gcc/config/gcn/gcn.cc                    | 17 +++++++++++------
 gcc/config/gcn/gen-gcn-device-macros.awk |  4 +++-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 82fc6ff1e413..b0c06d5e6320 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -6671,12 +6671,17 @@ gcn_hsa_declare_function_name (FILE *file, const char 
*name,
 
 #if 1
   /* The following is YAML embedded in assembler; tabs are not allowed.  */
-  fputs ("        .amdgpu_metadata\n"
-        "        amdhsa.version:\n"
-        "          - 1\n"
-        "          - 0\n"
-        "        amdhsa.kernels:\n"
-        "          - .name: ", file);
+
+  /* 'amdhsa.version': code object V3 = 1.0, V4 = 1.1, V5/V6 = 1.2.  */
+  /* Keep in sync with 'amdhsa-code-object' in gen-gcn-device-macros.awk.  */
+  fprintf (file,
+          "        .amdgpu_metadata\n"
+          "        amdhsa.version:\n"
+          "          - 1\n"
+          "          - %d\n"
+          "        amdhsa.kernels:\n"
+          "          - .name: ",
+          gcn_devices[gcn_arch].generic_version ? 2 /* V6 */ : 1 /* V4 */);
   assemble_name (file, name);
   fputs ("\n            .symbol: ", file);
   assemble_name (file, name);
diff --git a/gcc/config/gcn/gen-gcn-device-macros.awk 
b/gcc/config/gcn/gen-gcn-device-macros.awk
index aa271004c27b..d227e6fcedfd 100644
--- a/gcc/config/gcn/gen-gcn-device-macros.awk
+++ b/gcc/config/gcn/gen-gcn-device-macros.awk
@@ -117,7 +117,9 @@ BEGIN {
 # same. - LLVM <= 17 defaults to 4 while LLVM >= 18 defaults to 5.
 # GCC supports LLVM >= 13.0.1 and only LLVM >= 14 supports version 5.
 # Code object V6 is supported since LLVM 19.
-
+#
+# Keep in sync with 'amdhsa.version' in gcn.cc
+#
 END {
   print ""
   print ""

Reply via email to