Patchwork strlenopt improvements

login
register
mail settings
Submitter Eric Botcazou
Date Nov. 5, 2011, 10:44 a.m.
Message ID <201111051144.28263.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/123833/
State New
Headers show

Comments

Eric Botcazou - Nov. 5, 2011, 10:44 a.m.
> The man page is outdated, stpcpy is a standard POSIX2008 function.

Sorry for being so 20th century-ish. :-)

> Anyway, in the other gcc.dg/strlenopt-* testcases for USE_GNU I was using
> the convention that the name ended with g (i.e. strlenopt-22g.c) and
> the test would start with:
> /* This test needs runtime that provides stpcpy function.  */
> /* { dg-do run { target *-*-linux* } } */
> instead of just
> /* { dg-do run } */

Thanks for the tip.  Tested on Solaris 8 and Linux, applied on the mainline.


2011-11-05  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/strlenopt-22g.c: New wrapper around...
	* gcc.dg/strlenopt-22.c: ...this.  Do not define USE_GNU and adjust.
Jakub Jelinek - Nov. 5, 2011, 11:22 a.m.
On Sat, Nov 05, 2011 at 11:44:27AM +0100, Eric Botcazou wrote:
> Thanks for the tip.  Tested on Solaris 8 and Linux, applied on the mainline.

Thanks.

> @@ -32,10 +31,9 @@ main ()
>    return 0;
>  }
>  
> -/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
> +/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" } } */
>  /* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen" } } */
> -/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
> +/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen" } } */
>  /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
>  /* { dg-final { scan-tree-dump-times "strchr \\(" 1 "strlen" } } */
> -/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen" } } */

This line perhaps could have been kept, just with s/1/0/ to also test
that when stpcpy prototype isn't provided we don't emit any stpcpy
calls in code that didn't originally have any of them.

	Jakub

Patch

Index: gcc.dg/strlenopt-22g.c
===================================================================
--- gcc.dg/strlenopt-22g.c	(revision 0)
+++ gcc.dg/strlenopt-22g.c	(revision 0)
@@ -0,0 +1,14 @@ 
+/* This test needs runtime that provides stpcpy function.  */
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-options "-O2 -fdump-tree-strlen" } */
+
+#define USE_GNU
+#include "strlenopt-22.c"
+
+/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "strchr \\(" 1 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen" } } */
+/* { dg-final { cleanup-tree-dump "strlen" } } */
Index: gcc.dg/strlenopt-22.c
===================================================================
--- gcc.dg/strlenopt-22.c	(revision 181007)
+++ gcc.dg/strlenopt-22.c	(working copy)
@@ -1,7 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-O2 -fdump-tree-strlen" } */
 
-#define USE_GNU
 #include "strlenopt.h"
 
 __attribute__((noinline, noclone)) size_t
@@ -32,10 +31,9 @@  main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" } } */
 /* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen" } } */
-/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
+/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen" } } */
 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
 /* { dg-final { scan-tree-dump-times "strchr \\(" 1 "strlen" } } */
-/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen" } } */
 /* { dg-final { cleanup-tree-dump "strlen" } } */