Patchwork [testsuite] Fix gcc.c-torture/execute/pr45636.c on systems without mempcpy

login
register
mail settings
Submitter Steve Ellcey
Date Nov. 5, 2010, 5:04 p.m.
Message ID <201011051704.oA5H4lL13726@lucas.cup.hp.com>
Download mbox | patch
Permalink /patch/70270/
State New
Headers show

Comments

Steve Ellcey - Nov. 5, 2010, 5:04 p.m.
The test gcc.c-torture/execute/pr45636.c is failing on IA64 HP-UX when
compiled with -Os because with that optimization level the call to
mempcpy is not inlined and HP-UX does not have the mempcpy function in
libc (mempcpy is a GNU extension).

This patch moves gcc.c-torture/execute/pr45636.c to
gcc.dg/torture/pr45636.c so that we can use dg- directives and then uses
a new check I created to see if mempcpy exists before running the test. 
I also modified check_function_available (which my new test uses) to use
-fno-builtin when checking to see if a function exists so that we don't
get warning messages (or accidently inline) a function call when we were
trying to check to see if that function exists.

Tested on IA64 HP-UX and Linux and on x86 Linux with no regressions.

OK to checkin?

Steve Ellcey
sje@cup.hp.com



2010-11-05  Steve Ellcey  <sje@cup.hp.com>

	* lib/target-supports.exp (check_function_available): Use -fno-builtin.
	* (check_effective_target_mempcpy): New.
	* gcc.c-torture/execute/pr45636.c: Move this...
	* gcc.dg/torture/pr45636.c: to here.  Add add dg- directives.
Richard Henderson - Nov. 5, 2010, 5:38 p.m.
On 11/05/2010 10:04 AM, Steve Ellcey wrote:
> 	* lib/target-supports.exp (check_function_available): Use -fno-builtin.
> 	* (check_effective_target_mempcpy): New.
> 	* gcc.c-torture/execute/pr45636.c: Move this...
> 	* gcc.dg/torture/pr45636.c: to here.  Add add dg- directives.

Ok.


r~

Patch

Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 166346)
+++ lib/target-supports.exp	(working copy)
@@ -1366,7 +1366,7 @@  proc check_function_available { function
 	#endif
 	char $function ();
 	int main () { $function (); }
-    }]]
+    }] "-fno-builtin" ]
 }
 
 # Returns true iff "fork" is available on the target system.
@@ -3741,3 +3741,9 @@  proc check_effective_target_run_expensiv
     }
     return 0
 }
+
+# Returns 1 if "mempcpy" is available on the target system.
+
+proc check_effective_target_mempcpy {} {
+    return [check_function_available "mempcpy"]
+}
Index: gcc.c-torture/execute/pr45636.c
===================================================================
--- gcc.c-torture/execute/pr45636.c	(revision 166346)
+++ gcc.c-torture/execute/pr45636.c	(working copy)
@@ -1,75 +0,0 @@ 
-/* PR fortran/45636 */
-
-typedef __SIZE_TYPE__ size_t;
-void *memcpy (void *__restrict__, const void *__restrict__, size_t);
-void *mempcpy (void *__restrict__, const void *__restrict__, size_t);
-void *memset (void *, int, size_t);
-int memcmp (const void *, const void *, size_t);
-extern void abort (void);
-
-struct A { int i; char c[32]; } a[2];
-
-__attribute__((noinline, noclone)) int
-f1 (char *p, int q, int z)
-{
-  memcpy (p, "abcd", 4);
-  if (q)
-    z = z + 123;
-  else
-    z *= 114;
-  memset (p + 4, ' ', 2);
-  return z;
-}
-
-__attribute__((noinline, noclone)) void
-f2 (void)
-{
-  char *p = mempcpy (&a[0].c[13], "123456", 4);
-  memset (p, '7', 3);
-}
-
-__attribute__((noinline, noclone)) void
-f3 (struct A *p)
-{
-  p++;
-  char *q = &p->c[10];
-  memcpy (q + 4, "__1234567" + 2, 7);
-  memset (&p->c[21], '9', 3);
-}
-
-__attribute__((noinline, noclone)) void
-f4 (void)
-{
-  memcpy (&a[0].c[10], "0123456789", 10);
-  memset (&a[0].c[13], ' ', 3);
-}
-
-__attribute__((noinline, noclone)) void
-check (const char *p, const char *str, size_t size)
-{
-  const char *q;
-  for (q = (const char *) &a; q < p; q++)
-    if (*q)
-      abort ();
-  if (memcmp (p, str, size) != 0)
-    abort ();
-  for (q = p + size; q < (const char *) (&a[0] + 2); q++)
-    if (*q)
-      abort ();
-  memset (&a, '\0', sizeof a);
-}
-
-int
-main (void)
-{
-  if (f1 (&a[0].c[7], 1, 2) != 125)
-    abort ();
-  check (&a[0].c[7], "abcd  ", 6);
-  f2 ();
-  check (&a[0].c[13], "1234777", 7);
-  f3 (&a[0]);
-  check (&a[1].c[14], "1234567999", 10);
-  f4 ();
-  check (&a[0].c[10], "012   6789", 10);
-  return 0;
-}
Index: gcc.dg/torture/pr45636.c
===================================================================
--- gcc.dg/torture/pr45636.c	(revision 166227)
+++ gcc.dg/torture/pr45636.c	(working copy)
@@ -1,3 +1,5 @@ 
+/* { dg-do run } */
+/* { dg-require-effective-target mempcpy } */
 /* PR fortran/45636 */
 
 typedef __SIZE_TYPE__ size_t;