From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 20F1039B8C18; Thu, 22 Apr 2021 16:52:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20F1039B8C18 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r8-10905] rtlanal: Another fix for VOIDmode MEMs [PR98601] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-8 X-Git-Oldrev: e1ef85b4f29e04e97f2ac0998bfd62bac50428b9 X-Git-Newrev: b7cac48e100fc70d361ce98be27f209659c4b0e9 Message-Id: <20210422165236.20F1039B8C18@sourceware.org> Date: Thu, 22 Apr 2021 16:52:36 +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: Thu, 22 Apr 2021 16:52:36 -0000 https://gcc.gnu.org/g:b7cac48e100fc70d361ce98be27f209659c4b0e9 commit r8-10905-gb7cac48e100fc70d361ce98be27f209659c4b0e9 Author: Jakub Jelinek Date: Sat Apr 10 12:46:09 2021 +0200 rtlanal: Another fix for VOIDmode MEMs [PR98601] This is a sequel to the PR85022 changes, inline-asm can (unfortunately) introduce VOIDmode MEMs and in PR85022 they have been changed so that we don't pretend we know their size (as opposed to assuming they have zero size). This time we ICE in rtx_addr_can_trap_p_1 because it assumes that all memory but BLKmode has known size. The patch just treats VOIDmode MEMs like BLKmode in that regard. And, the STRICT_ALIGNMENT change is needed because VOIDmode has GET_MODE_SIZE of 0 and we don't want to check if something is a multiple of 0. 2021-04-10 Jakub Jelinek PR rtl-optimization/98601 * rtlanal.c (rtx_addr_can_trap_p_1): Allow in assert unknown size not just for BLKmode, but also for VOIDmode. For STRICT_ALIGNMENT unaligned_mems handle VOIDmode like BLKmode. * gcc.dg/torture/pr98601.c: New test. (cherry picked from commit e68ac8c2b46997af1464f2549ac520a192c928b1) Diff: --- gcc/rtlanal.c | 9 +++++++-- gcc/testsuite/gcc.dg/torture/pr98601.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 96763957cfc..acfdac94e0b 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -461,11 +461,16 @@ rtx_addr_can_trap_p_1 (const_rtx x, poly_int64 offset, poly_int64 size, machine_mode mode, bool unaligned_mems) { enum rtx_code code = GET_CODE (x); - gcc_checking_assert (mode == BLKmode || known_size_p (size)); + gcc_checking_assert (mode == BLKmode + || mode == VOIDmode + || known_size_p (size)); /* The offset must be a multiple of the mode size if we are considering unaligned memory references on strict alignment machines. */ - if (STRICT_ALIGNMENT && unaligned_mems && mode != BLKmode) + if (STRICT_ALIGNMENT + && unaligned_mems + && mode != BLKmode + && mode != VOIDmode) { poly_int64 actual_offset = offset; diff --git a/gcc/testsuite/gcc.dg/torture/pr98601.c b/gcc/testsuite/gcc.dg/torture/pr98601.c new file mode 100644 index 00000000000..ee9d076c02d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98601.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/98601 */ +/* { dg-do compile } */ + +void +foo (void *p) +{ + asm ("" : "=m" (*p)); /* { dg-warning "dereferencing 'void \\*' pointer" } */ +} + +void +bar (void *p) +{ + asm volatile ("" : : "m" (*p)); /* { dg-warning "dereferencing 'void \\*' pointer" } */ +}