From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id A0633385E02C; Tue, 20 Jul 2021 07:20:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0633385E02C MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: =?utf-8?q?=5Bgcc_r12-2408=5D_=5Bgcn=5D_Work-around_libgomp_=27erro?= =?utf-8?q?r=3A_array_subscript_0_is_outside_array_bounds_of_=E2=80=98=5F=5F?= =?utf-8?q?lds_struct_gomp=5F?= X-Act-Checkin: gcc X-Git-Author: Thomas Schwinge X-Git-Refname: refs/heads/master X-Git-Oldrev: 6d4da4aeef5b20f7f9693ddc27d26740d0dbe36c X-Git-Newrev: 8168338684fc2bed576bb09202c63b3e9e678d92 Message-Id: <20210720072044.A0633385E02C@sourceware.org> Date: Tue, 20 Jul 2021 07:20:44 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2021 07:20:44 -0000 https://gcc.gnu.org/g:8168338684fc2bed576bb09202c63b3e9e678d92 commit r12-2408-g8168338684fc2bed576bb09202c63b3e9e678d92 Author: Thomas Schwinge Date: Mon Jul 19 23:11:38 2021 +0200 [gcn] Work-around libgomp 'error: array subscript 0 is outside array bounds of ‘__lds struct gomp_thread * __lds[0]’ [-Werror=array-bounds]' some more [PR101484] With yesterday's commit 9f2bc5077debef2b046b6c10d38591ac324ad8b5 "[gcn] Work-around libgomp 'error: array subscript 0 is outside array bounds of ‘__lds struct gomp_thread * __lds[0]’ [-Werror=array-bounds]' [PR101484]", I did defuse the "unexpected" '-Werror=array-bounds' diagnostics that we see as of commit a110855667782dac7b674d3e328b253b3b3c919b "Correct handling of variable offset minus constant in -Warray-bounds [PR100137]". However, these '#pragma GCC diagnostic [...]' directives cause some code generation changes (that seems unexpected, problematic!), which results in a lot (ten thousands) of 'GCN team arena exhausted' run-time diagnostics, also leading to a few FAILs: PASS: libgomp.c/../libgomp.c-c++-common/for-11.c (test for excess errors) [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-11.c execution test PASS: libgomp.c/../libgomp.c-c++-common/for-12.c (test for excess errors) [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-12.c execution test PASS: libgomp.c/../libgomp.c-c++-common/for-3.c (test for excess errors) [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-3.c execution test PASS: libgomp.c/../libgomp.c-c++-common/for-5.c (test for excess errors) [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-5.c execution test PASS: libgomp.c/../libgomp.c-c++-common/for-6.c (test for excess errors) [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-6.c execution test PASS: libgomp.c/../libgomp.c-c++-common/for-9.c (test for excess errors) [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-9.c execution test Same for 'libgomp.c++'. It remains to be analyzed how '#pragma GCC diagnostic [...]' directives can cause code generation changes; for now I'm working around the "unexpected" '-Werror=array-bounds' diagnostics differently. Overall, still awaiting a different solution, of course. libgomp/ PR target/101484 * configure.tgt [amdgcn*-*-*] (XCFLAGS): Add '-Wno-error=array-bounds'. * config/gcn/team.c: Remove '-Werror=array-bounds' work-around. * libgomp.h [__AMDGCN__]: Likewise. Diff: --- libgomp/config/gcn/team.c | 3 --- libgomp/configure.tgt | 3 +++ libgomp/libgomp.h | 12 ------------ 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c index 94ce2f2dfeb..627210ea407 100644 --- a/libgomp/config/gcn/team.c +++ b/libgomp/config/gcn/team.c @@ -65,12 +65,9 @@ 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) diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt index fe2bf1dac51..d4f1e741b5a 100644 --- a/libgomp/configure.tgt +++ b/libgomp/configure.tgt @@ -173,6 +173,9 @@ case "${target}" in amdgcn*-*-*) config_path="gcn accel" + + #TODO PR101484 + XCFLAGS="$XCFLAGS -Wno-error=array-bounds" ;; *) diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 4159cbe3334..8d25dc8e2a8 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -128,10 +128,7 @@ 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. */ @@ -162,11 +159,8 @@ 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 @@ -795,19 +789,13 @@ 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) {