public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [r12-3899 Regression] FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7 on Linux/x86_64
@ 2021-09-27 18:28 sunil.k.pandey
  2021-09-28  7:20 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: sunil.k.pandey @ 2021-09-27 18:28 UTC (permalink / raw)
  To: gcc-patches, gcc-regression, rguenther

On Linux/x86_64,

d06dc8a2c73735e9496f434787ba4c93ceee5eea is the first bad commit
commit d06dc8a2c73735e9496f434787ba4c93ceee5eea
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Sep 27 13:36:12 2021 +0200

    middle-end/102450 - avoid type_for_size for non-existing modes

caused

FAIL: gcc.dg/out-of-bounds-1.c  (test for warnings, line 12)
FAIL: gcc.dg/pr78408-1.c scan-tree-dump-times fab1 "after previous" 17
FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7

with GCC configured with

../../gcc/configure --prefix=/local/skpandey/gccwork/toolwork/gcc-bisect-master/master/r12-3899/usr --enable-clocale=gnu --with-system-zlib --with-demangler-in-ld --with-fpmath=sse --enable-languages=c,c++,fortran --enable-cet --without-isl --enable-libmpx x86_64-linux --disable-bootstrap

To reproduce:

$ cd {build_dir}/gcc && make check RUNTESTFLAGS="dg.exp=gcc.dg/out-of-bounds-1.c --target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="dg.exp=gcc.dg/out-of-bounds-1.c --target_board='unix{-m64\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="dg.exp=gcc.dg/pr78408-1.c --target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="dg.exp=gcc.dg/pr78408-1.c --target_board='unix{-m64\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="dg.exp=gcc.dg/strlenopt-13.c --target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="dg.exp=gcc.dg/strlenopt-13.c --target_board='unix{-m64\ -march=cascadelake}'"

(Please do not reply to this email, for question about this report, contact me at skpgkp2 at gmail dot com)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [r12-3899 Regression] FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7 on Linux/x86_64
  2021-09-27 18:28 [r12-3899 Regression] FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7 on Linux/x86_64 sunil.k.pandey
@ 2021-09-28  7:20 ` Richard Biener
  2021-09-28 15:06   ` Martin Sebor
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2021-09-28  7:20 UTC (permalink / raw)
  To: sunil.k.pandey; +Cc: gcc-patches, richard.earnshaw, msebor

On Mon, 27 Sep 2021, sunil.k.pandey wrote:

> On Linux/x86_64,
> 
> d06dc8a2c73735e9496f434787ba4c93ceee5eea is the first bad commit
> commit d06dc8a2c73735e9496f434787ba4c93ceee5eea
> Author: Richard Biener <rguenther@suse.de>
> Date:   Mon Sep 27 13:36:12 2021 +0200
> 
>     middle-end/102450 - avoid type_for_size for non-existing modes
> 
> caused
> 
> FAIL: gcc.dg/out-of-bounds-1.c  (test for warnings, line 12)
> FAIL: gcc.dg/pr78408-1.c scan-tree-dump-times fab1 "after previous" 17
> FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7

After the change the new memcpy inlining limit using MOVE_MAX * MOVE_RATIO
comes into play and ends up using an OImode move which previously was
disregarded as there's no __int256 standard type in the frontend
(but now we build such type anyway after verifying the mode exists and
it has move support).

For example gcc.dg/out-of-bounds-1.c which looks like

void ProjectOverlay(const float localTextureAxis[2], char *lump)
{
   const void *d = &localTextureAxis;
   int size = sizeof(float)*8 ;
   __builtin_memcpy( &lump[ 0 ], d, size );  /* { dg-warning "reading" } 
*/
}

gets turned into

        movq    %rdi, -8(%rsp)
        vmovdqu64       -8(%rsp), %ymm31
        vmovdqu64       %ymm31, (%rsi)

which I guess is good but then the diagnostic is no longer emitted
because -Wstringop-overread only applies to the builtin.  Usually
we avoid the folding in such a case but

              /* Detect out-of-bounds accesses without issuing warnings.
                 Avoid folding out-of-bounds copies but to avoid false
                 positives for unreachable code defer warning until after
                 DCE has worked its magic.
                 -Wrestrict is still diagnosed.  */
              if (int warning = check_bounds_or_overlap (as_a <gcall 
*>(stmt),
                                                         dest, src, len, 
len,
                                                         false, false))
                if (warning != OPT_Wrestrict)
                  return false;

does not seem to trigger here.  Changing the testcase to

void ProjectOverlay(const float localTextureAxis[2], char *lump)
{
   const void *d = &localTextureAxis;
   int size = sizeof(float)*4 ;
   __builtin_memcpy( &lump[ 0 ], d, size );  /* { dg-warning "reading" } 
*/
}

also fails to warn.

Richard.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [r12-3899 Regression] FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7 on Linux/x86_64
  2021-09-28  7:20 ` Richard Biener
@ 2021-09-28 15:06   ` Martin Sebor
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Sebor @ 2021-09-28 15:06 UTC (permalink / raw)
  To: Richard Biener, sunil.k.pandey; +Cc: gcc-patches, richard.earnshaw, msebor

On 9/28/21 1:20 AM, Richard Biener wrote:
> On Mon, 27 Sep 2021, sunil.k.pandey wrote:
> 
>> On Linux/x86_64,
>>
>> d06dc8a2c73735e9496f434787ba4c93ceee5eea is the first bad commit
>> commit d06dc8a2c73735e9496f434787ba4c93ceee5eea
>> Author: Richard Biener <rguenther@suse.de>
>> Date:   Mon Sep 27 13:36:12 2021 +0200
>>
>>      middle-end/102450 - avoid type_for_size for non-existing modes
>>
>> caused
>>
>> FAIL: gcc.dg/out-of-bounds-1.c  (test for warnings, line 12)
>> FAIL: gcc.dg/pr78408-1.c scan-tree-dump-times fab1 "after previous" 17
>> FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7
> 
> After the change the new memcpy inlining limit using MOVE_MAX * MOVE_RATIO
> comes into play and ends up using an OImode move which previously was
> disregarded as there's no __int256 standard type in the frontend
> (but now we build such type anyway after verifying the mode exists and
> it has move support).
> 
> For example gcc.dg/out-of-bounds-1.c which looks like
> 
> void ProjectOverlay(const float localTextureAxis[2], char *lump)
> {
>     const void *d = &localTextureAxis;
>     int size = sizeof(float)*8 ;
>     __builtin_memcpy( &lump[ 0 ], d, size );  /* { dg-warning "reading" }
> */
> }
> 
> gets turned into
> 
>          movq    %rdi, -8(%rsp)
>          vmovdqu64       -8(%rsp), %ymm31
>          vmovdqu64       %ymm31, (%rsi)
> 
> which I guess is good but then the diagnostic is no longer emitted
> because -Wstringop-overread only applies to the builtin.  Usually
> we avoid the folding in such a case but
> 
>                /* Detect out-of-bounds accesses without issuing warnings.
>                   Avoid folding out-of-bounds copies but to avoid false
>                   positives for unreachable code defer warning until after
>                   DCE has worked its magic.
>                   -Wrestrict is still diagnosed.  */
>                if (int warning = check_bounds_or_overlap (as_a <gcall
> *>(stmt),
>                                                           dest, src, len,
> len,
>                                                           false, false))
>                  if (warning != OPT_Wrestrict)
>                    return false;

The check_bounds_or_overlap() call only implements -Wrestrict and
a small subset of -Warray-bounds (the subset issued for forming
out-of-bounds pointers by built-ins).  It's a limitation/bug in
the gimple-ssa-warn-restrict.c code that it doesn't detect
the problem (it's confused by taking the address of a pointer).

To let the test pass I suggest either bumping up the size or making
it an odd number (or anything else that's not a power of 2).

> 
> does not seem to trigger here.  Changing the testcase to
> 
> void ProjectOverlay(const float localTextureAxis[2], char *lump)
> {
>     const void *d = &localTextureAxis;
>     int size = sizeof(float)*4 ;
>     __builtin_memcpy( &lump[ 0 ], d, size );  /* { dg-warning "reading" }
> */
> }
> 
> also fails to warn.

The very late -Wstringop-{overflow,overread} warnings that run just
before expansion have historically only worked for built-in calls.
Now that they are in a GIMPLE pass of their own as opposed to
working with trees in builtins.c, it will be easy to handle plain
stores as well.  It's on my list of things to do.

Martin

> 
> Richard.
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-28 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 18:28 [r12-3899 Regression] FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7 on Linux/x86_64 sunil.k.pandey
2021-09-28  7:20 ` Richard Biener
2021-09-28 15:06   ` Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).