]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[gcn] Work-around libgomp 'error: array subscript 0 is outside array bounds of ‘__lds...
authorThomas Schwinge <thomas@codesourcery.com>
Fri, 16 Jul 2021 17:12:02 +0000 (19:12 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Mon, 19 Jul 2021 08:26:12 +0000 (10:26 +0200)
... seen as of commit a110855667782dac7b674d3e328b253b3b3c919b "Correct
handling of variable offset minus constant in -Warray-bounds [PR100137]".

Awaiting a different solution, of course.

libgomp/
PR target/101484
* config/gcn/team.c: Apply '-Werror=array-bounds' work-around.
* libgomp.h [__AMDGCN__]: Likewise.

libgomp/config/gcn/team.c
libgomp/libgomp.h

index 627210ea4071cf66bf75f9c3b47281831dd775bd..94ce2f2dfebe4081ece7157bdca92b941d4323af 100644 (file)
@@ -65,9 +65,12 @@ gomp_gcn_enter_kernel (void)
       void * __lds *arena_start = (void * __lds *)TEAM_ARENA_START;
       void * __lds *arena_free = (void * __lds *)TEAM_ARENA_FREE;
       void * __lds *arena_end = (void * __lds *)TEAM_ARENA_END;
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Warray-bounds" /*TODO PR101484 */
       *arena_start = team_arena;
       *arena_free = team_arena;
       *arena_end = team_arena + TEAM_ARENA_SIZE;
+# pragma GCC diagnostic pop
 
       /* Allocate and initialize the team-local-storage data.  */
       struct gomp_thread *thrs = team_malloc_cleared (sizeof (*thrs)
index 8d25dc8e2a8518421bacb091690e28ac0c8fc8a5..4159cbe33347336058e976391f0c9c7ca101f891 100644 (file)
@@ -128,7 +128,10 @@ team_malloc (size_t size)
        : "=v"(result) : "v"(TEAM_ARENA_FREE), "v"(size), "e"(1L) : "memory");
 
   /* Handle OOM.  */
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Warray-bounds" /*TODO PR101484 */
   if (result + size > *(void * __lds *)TEAM_ARENA_END)
+# pragma GCC diagnostic pop
     {
       /* While this is experimental, let's make sure we know when OOM
         happens.  */
@@ -159,8 +162,11 @@ team_free (void *ptr)
      However, if we fell back to using heap then we should free it.
      It would be better if this function could be a no-op, but at least
      LDS loads are cheap.  */
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Warray-bounds" /*TODO PR101484 */
   if (ptr < *(void * __lds *)TEAM_ARENA_START
       || ptr >= *(void * __lds *)TEAM_ARENA_END)
+# pragma GCC diagnostic pop
     free (ptr);
 }
 #else
@@ -789,13 +795,19 @@ static inline struct gomp_thread *gcn_thrs (void)
 {
   /* The value is at the bottom of LDS.  */
   struct gomp_thread * __lds *thrs = (struct gomp_thread * __lds *)4;
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Warray-bounds" /*TODO PR101484 */
   return *thrs;
+# pragma GCC diagnostic pop
 }
 static inline void set_gcn_thrs (struct gomp_thread *val)
 {
   /* The value is at the bottom of LDS.  */
   struct gomp_thread * __lds *thrs = (struct gomp_thread * __lds *)4;
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Warray-bounds" /*TODO PR101484 */
   *thrs = val;
+# pragma GCC diagnostic pop
 }
 static inline struct gomp_thread *gomp_thread (void)
 {