https://gcc.gnu.org/g:48ff90a2f1c10634cad5edf43f40f31feafb8607

commit 48ff90a2f1c10634cad5edf43f40f31feafb8607
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Mon Apr 21 22:32:26 2025 +0000

    GCN: Properly switch sections in 'gcn_hsa_declare_function_name' [PR119737]
    
    There are GCN/C++ target as well as offloading codes, where the hard-coded
    section names in 'gcn_hsa_declare_function_name' do not fit, and assembly 
thus
    fails:
    
        LLVM ERROR: Size expression must be absolute.
    
    This commit progresses GCN target:
    
        [-FAIL: g++.dg/init/call1.C  -std=gnu++17 (internal compiler error: 
Aborted signal terminated program as)-]
        [-FAIL:-]{+PASS:+} g++.dg/init/call1.C  -std=gnu++17 (test for excess 
errors)
        [-UNRESOLVED:-]{+PASS:+} g++.dg/init/call1.C  -std=gnu++17 
[-compilation failed to produce executable-]{+execution test+}
        [-FAIL: g++.dg/init/call1.C  -std=gnu++26 (internal compiler error: 
Aborted signal terminated program as)-]
        [-FAIL:-]{+PASS:+} g++.dg/init/call1.C  -std=gnu++26 (test for excess 
errors)
        [-UNRESOLVED:-]{+PASS:+} g++.dg/init/call1.C  -std=gnu++26 
[-compilation failed to produce executable-]{+execution test+}
        UNSUPPORTED: g++.dg/init/call1.C  -std=gnu++98: exception handling not 
supported
    
    ..., and GCN offloading:
    
        [-XFAIL: libgomp.c++/target-exceptions-throw-1.C (internal compiler 
error: Aborted signal terminated program as)-]
        [-XFAIL: libgomp.c++/target-exceptions-throw-1.C PR119737 at line 7 
(test for bogus messages, line )-]
        [-XFAIL:-]{+PASS:+} libgomp.c++/target-exceptions-throw-1.C (test for 
excess errors)
        [-UNRESOLVED:-]{+PASS:+} libgomp.c++/target-exceptions-throw-1.C 
[-compilation failed to produce executable-]{+execution test+}
        {+PASS: libgomp.c++/target-exceptions-throw-1.C output pattern test+}
    
        [-XFAIL: libgomp.c++/target-exceptions-throw-2.C (internal compiler 
error: Aborted signal terminated program as)-]
        [-XFAIL: libgomp.c++/target-exceptions-throw-2.C PR119737 at line 7 
(test for bogus messages, line )-]
        [-XFAIL:-]{+PASS:+} libgomp.c++/target-exceptions-throw-2.C (test for 
excess errors)
        [-UNRESOLVED:-]{+PASS:+} libgomp.c++/target-exceptions-throw-2.C 
[-compilation failed to produce executable-]{+execution test+}
        {+PASS: libgomp.c++/target-exceptions-throw-2.C output pattern test+}
    
        [-XFAIL: libgomp.oacc-c++/exceptions-throw-1.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
(internal compiler error: Aborted signal terminated program as)-]
        [-XFAIL: libgomp.oacc-c++/exceptions-throw-1.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
PR119737 at line 7 (test for bogus messages, line )-]
        [-XFAIL:-]{+PASS:+} libgomp.oacc-c++/exceptions-throw-1.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
(test for excess errors)
        [-UNRESOLVED:-]{+PASS:+} libgomp.oacc-c++/exceptions-throw-1.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
[-compilation failed to produce executable-]{+execution test+}
        {+PASS: libgomp.oacc-c++/exceptions-throw-1.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
output pattern test+}
    
        [-XFAIL: libgomp.oacc-c++/exceptions-throw-2.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
(internal compiler error: Aborted signal terminated program as)-]
        [-XFAIL: libgomp.oacc-c++/exceptions-throw-2.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
PR119737 at line 9 (test for bogus messages, line )-]
        [-XFAIL:-]{+PASS:+} libgomp.oacc-c++/exceptions-throw-2.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
(test for excess errors)
        [-UNRESOLVED:-]{+PASS:+} libgomp.oacc-c++/exceptions-throw-2.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
[-compilation failed to produce executable-]{+execution test+}
        {+PASS: libgomp.oacc-c++/exceptions-throw-2.C 
-DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  
output pattern test+}
    
            PR target/119737
            gcc/
            * config/gcn/gcn.cc (gcn_hsa_declare_function_name): Properly
            switch sections.
            libgomp/
            * testsuite/libgomp.c++/target-exceptions-throw-1.C: Remove
            PR119737 XFAILing.
            * testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
            * testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.
            * testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
    
    Co-authored-by: Thomas Schwinge <tschwi...@baylibre.com>
    (cherry picked from commit dfc43afe719898c3eafbed37fac7e6809d8b97ab)

Diff:
---
 gcc/ChangeLog.omp                                         |  8 ++++++++
 gcc/config/gcn/gcn.cc                                     |  6 +++---
 libgomp/ChangeLog.omp                                     | 11 +++++++++++
 libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C |  3 ---
 libgomp/testsuite/libgomp.c++/target-exceptions-throw-2.C |  3 ---
 libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C   |  3 ---
 libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C   |  3 ---
 7 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index d46ba452de58..220e23398055 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,5 +1,13 @@
 2025-04-25  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       Backported from trunk:
+       2025-04-25  Andrew Pinski  <quic_apin...@quicinc.com>
+                   Thomas Schwinge  <tschwi...@baylibre.com>
+
+       PR target/119737
+       * config/gcn/gcn.cc (gcn_hsa_declare_function_name): Properly
+       switch sections.
+
        Backported from trunk:
        2024-08-07  Julian Brown  <jul...@codesourcery.com>
                    Tobias Burnus  <tob...@baylibre.com>
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 0cad912b90e7..673c0484a36e 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -6708,8 +6708,8 @@ gcn_hsa_declare_function_name (FILE *file, const char 
*name,
   if (avgpr % vgpr_block_size)
     avgpr += vgpr_block_size - (avgpr % vgpr_block_size);
 
-  fputs ("\t.rodata\n"
-        "\t.p2align\t6\n"
+  switch_to_section (readonly_data_section);
+  fputs ("\t.p2align\t6\n"
         "\t.amdhsa_kernel\t", file);
   assemble_name (file, name);
   fputs ("\n", file);
@@ -6820,7 +6820,7 @@ gcn_hsa_declare_function_name (FILE *file, const char 
*name,
   fputs ("        .end_amdgpu_metadata\n", file);
 #endif
 
-  fputs ("\t.text\n", file);
+  switch_to_section (current_function_section ());
   fputs ("\t.align\t256\n", file);
   fputs ("\t.type\t", file);
   assemble_name (file, name);
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 316aa05156c9..cfa267e6d889 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,5 +1,16 @@
 2025-04-25  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       Backported from trunk:
+       2025-04-25  Andrew Pinski  <quic_apin...@quicinc.com>
+                   Thomas Schwinge  <tschwi...@baylibre.com>
+
+       PR target/119737
+       * testsuite/libgomp.c++/target-exceptions-throw-1.C: Remove
+       PR119737 XFAILing.
+       * testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
+       * testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.
+       * testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
+
        Backported from trunk:
        2025-04-25  Thomas Schwinge  <tschwi...@baylibre.com>
 
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C
index 246706150cc9..a4e7a104ceec 100644
--- a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C
@@ -4,9 +4,6 @@
    { dg-additional-options -fexceptions } */
 /* { dg-additional-options -fdump-tree-optimized-raw }
    { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
-/* { dg-bogus {Size expression must be absolute\.} PR119737 { target 
offload_target_amdgcn xfail *-*-* } 0 }
-   { dg-ice PR119737 { offload_target_amdgcn } }
-   { dg-excess-errors {'mkoffload' failures etc.} { xfail 
offload_target_amdgcn } } */
 
 #include "../libgomp.oacc-c++/exceptions-throw-1.C"
 
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-2.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-2.C
index e85e6c36c422..97f484589d4f 100644
--- a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-2.C
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-2.C
@@ -4,9 +4,6 @@
    { dg-additional-options -fexceptions } */
 /* { dg-additional-options -fdump-tree-optimized-raw }
    { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
-/* { dg-bogus {Size expression must be absolute\.} PR119737 { target 
offload_target_amdgcn xfail *-*-* } 0 }
-   { dg-ice PR119737 { offload_target_amdgcn } }
-   { dg-excess-errors {'mkoffload' failures etc.} { xfail 
offload_target_amdgcn } } */
 
 #include "../libgomp.oacc-c++/exceptions-throw-2.C"
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C
index f2ef75193c81..08c576611741 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C
@@ -4,9 +4,6 @@
    { dg-additional-options -fexceptions } */
 /* { dg-additional-options -fdump-tree-optimized-raw }
    { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
-/* { dg-bogus {Size expression must be absolute\.} PR119737 { target { 
openacc_radeon_accel_selected && __OPTIMIZE__ } xfail *-*-* } 0 }
-   { dg-ice PR119737 { openacc_radeon_accel_selected && __OPTIMIZE__ } }
-   { dg-excess-errors {'mkoffload' failure etc.} { xfail { 
openacc_radeon_accel_selected && __OPTIMIZE__ } } } */
 
 /* See also '../libgomp.c++/target-exceptions-throw-1.C'.  */
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C
index f6dc9702b690..a7408cdb3752 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C
@@ -6,9 +6,6 @@
    { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
 /* { dg-bogus {undefined symbol: typeinfo name for MyException} PR119806 { 
target { openacc_radeon_accel_selected && { ! __OPTIMIZE__ } } xfail *-*-* } 0 }
    { dg-excess-errors {'mkoffload' failure etc.} { xfail { 
openacc_radeon_accel_selected && { ! __OPTIMIZE__ } } } } */
-/* { dg-bogus {Size expression must be absolute\.} PR119737 { target { 
openacc_radeon_accel_selected && __OPTIMIZE__ } xfail *-*-* } 0 }
-   { dg-ice PR119737 { openacc_radeon_accel_selected && __OPTIMIZE__ } }
-   { dg-excess-errors {'mkoffload' failures etc.} { xfail { 
openacc_radeon_accel_selected && __OPTIMIZE__ } } } */
 /* { dg-bogus {Initial value type mismatch} PR119806 { target { 
openacc_nvidia_accel_selected && { ! __OPTIMIZE__ } } xfail *-*-* } 0 }
    { dg-excess-errors {'mkoffload' failure etc.} { xfail { 
openacc_nvidia_accel_selected && { ! __OPTIMIZE__ } } } } */

Reply via email to