* [Patch][testsuite] Fix a few test cases
@ 2014-12-12 19:38 Ryan Mansfield
2014-12-12 21:29 ` Mike Stump
2015-01-05 21:40 ` Jeff Law
0 siblings, 2 replies; 4+ messages in thread
From: Ryan Mansfield @ 2014-12-12 19:38 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
Hi,
Here are a few test tweaks. In 921202-1.c, if STACK_SIZE is used then
VLEN will blow the stack with 64bit longs. e.g. if STACK_SIZE == 512K
then 3 arrays of 32767 longs means at a minimum 767K of stack will be
used at -O0. In pr51447.c, the rbx global register is clobbering the rbx
of main's caller, which can cause test case crashes on return.
2014-12-12 Ryan Mansfield <rmansfield@qnx.com>
* gcc.c-torture/execute/921202-1.c: Adjust VLEN.
* gcc.c-torture/execute/pr51447.c: Restore rbx for x86-64.
* gcc.dg/cpp/trad/include.c: Exclude QNX targets.
OK?
Regards,
Ryan Mansfield
[-- Attachment #2: tests.diff --]
[-- Type: text/x-patch, Size: 2074 bytes --]
Index: gcc/testsuite/gcc.c-torture/execute/921202-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/921202-1.c (revision 218685)
+++ gcc/testsuite/gcc.c-torture/execute/921202-1.c (working copy)
@@ -2,7 +2,7 @@
#ifndef STACK_SIZE
#define VLEN 2055
#else
-#define VLEN ((STACK_SIZE/16) - 1)
+#define VLEN ((STACK_SIZE/32) - 1)
#endif
main ()
{
Index: gcc/testsuite/gcc.c-torture/execute/pr51447.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/pr51447.c (revision 218685)
+++ gcc/testsuite/gcc.c-torture/execute/pr51447.c (working copy)
@@ -14,6 +14,10 @@
main (void)
{
__label__ nonlocal_lab;
+#ifdef __x86_64__
+ void *rbx __asm ("rbx");
+ void *saved_rbx = rbx;
+#endif
__attribute__((noinline, noclone)) void
bar (void *func)
{
@@ -21,9 +25,15 @@
goto nonlocal_lab;
}
bar (&&nonlocal_lab);
+#ifdef __x86_64__
+ rbx = saved_rbx;
+#endif
return 1;
nonlocal_lab:
if (ptr != &&nonlocal_lab)
abort ();
+#ifdef __x86_64__
+ rbx = saved_rbx;
+#endif
return 0;
}
Index: gcc/testsuite/gcc.dg/cpp/trad/include.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/trad/include.c (revision 218685)
+++ gcc/testsuite/gcc.dg/cpp/trad/include.c (working copy)
@@ -1,11 +1,11 @@
/* Copyright (c) 2002 Free Software Foundation Inc. */
-/* Test that macros are not expanded in the <> quotes of #inlcude. */
+/* Test that macros are not expanded in the <> quotes of #include. */
/* vxWorksCommon.h uses the "#" operator to construct the name of an
include file, thus making the file incompatible with -traditional-cpp.
Newlib uses ## when including stdlib.h as of 2007-09-07. */
-/* { dg-do preprocess { target { { ! vxworks_kernel } && { ! newlib } } } } */
+/* { dg-do preprocess { target { { ! vxworks_kernel } && { ! newlib } && { ! *-*-qnx* }} } } */
#define __STDC__ 1 /* Stop complaints about non-ISO compilers. */
#define stdlib 1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch][testsuite] Fix a few test cases
2014-12-12 19:38 [Patch][testsuite] Fix a few test cases Ryan Mansfield
@ 2014-12-12 21:29 ` Mike Stump
2014-12-13 1:54 ` Ryan Mansfield
2015-01-05 21:40 ` Jeff Law
1 sibling, 1 reply; 4+ messages in thread
From: Mike Stump @ 2014-12-12 21:29 UTC (permalink / raw)
To: Ryan Mansfield; +Cc: gcc-patches
On Dec 12, 2014, at 11:38 AM, Ryan Mansfield <RMansfield@qnx.com> wrote:
>
> Here are a few test tweaks. In 921202-1.c, if STACK_SIZE is used then VLEN will blow the stack with 64bit longs. e.g. if STACK_SIZE == 512K then 3 arrays of 32767 longs means at a minimum 767K of stack will be used at -O0. In pr51447.c, the rbx global register is clobbering the rbx of main's caller, which can cause test case crashes on return.
>
> 2014-12-12 Ryan Mansfield <rmansfield@qnx.com>
>
> * gcc.c-torture/execute/921202-1.c: Adjust VLEN.
> * gcc.c-torture/execute/pr51447.c: Restore rbx for x86-64.
> * gcc.dg/cpp/trad/include.c: Exclude QNX targets.
>
> OK?
Ok for first and third part. The second one, I would like an rbx/x86_64 person to review.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch][testsuite] Fix a few test cases
2014-12-12 21:29 ` Mike Stump
@ 2014-12-13 1:54 ` Ryan Mansfield
0 siblings, 0 replies; 4+ messages in thread
From: Ryan Mansfield @ 2014-12-13 1:54 UTC (permalink / raw)
To: Mike Stump; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]
On 14-12-12 04:29 PM, Mike Stump wrote:
> On Dec 12, 2014, at 11:38 AM, Ryan Mansfield <RMansfield@qnx.com> wrote:
>>
>> Here are a few test tweaks. In 921202-1.c, if STACK_SIZE is used then VLEN will blow the stack with 64bit longs. e.g. if STACK_SIZE == 512K then 3 arrays of 32767 longs means at a minimum 767K of stack will be used at -O0. In pr51447.c, the rbx global register is clobbering the rbx of main's caller, which can cause test case crashes on return.
>>
>> 2014-12-12 Ryan Mansfield <rmansfield@qnx.com>
>>
>> * gcc.c-torture/execute/921202-1.c: Adjust VLEN.
>> * gcc.c-torture/execute/pr51447.c: Restore rbx for x86-64.
>> * gcc.dg/cpp/trad/include.c: Exclude QNX targets.
>>
>> OK?
>
> Ok for first and third part. The second one, I would like an rbx/x86_64 person to review.
Thanks. rbx is callee saved, and it's being clobbered.
e.g. on Linux x86-64
Breakpoint 1, main ()
at
/home/ryan/gnu/gcc/trunk/gcc/testsuite/gcc.c-torture/execute/pr51447.c:13
13 {
1: x/i $pc
=> 0x40054e <main>: push %rbp
(gdb) info reg rbx
rbx 0x0 0
(gdb) s
26 return 0;
1: x/i $pc
=> 0x400596 <main+72>: mov $0x0,%eax
(gdb) info reg rbx
rbx 0x400586 4195718r
The global register var docs say:
"A function that can alter the value of a global register variable
cannot safely be called from a function compiled without this variable,
because it could clobber the value the caller expects to find there on
return. Therefore, the function that is the entry point into the part of
the program that uses the global register variable must explicitly save
and restore the value that belongs to its caller."
The updated diff switches the test to use inline asm to save/restore rbx
instead of the local reg vars, but maybe there's a better way.
Regards,
Ryan Mansfield
[-- Attachment #2: tests.diff --]
[-- Type: text/x-patch, Size: 2191 bytes --]
Index: gcc/testsuite/gcc.c-torture/execute/921202-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/921202-1.c (revision 218685)
+++ gcc/testsuite/gcc.c-torture/execute/921202-1.c (working copy)
@@ -2,7 +2,7 @@
#ifndef STACK_SIZE
#define VLEN 2055
#else
-#define VLEN ((STACK_SIZE/16) - 1)
+#define VLEN ((STACK_SIZE/32) - 1)
#endif
main ()
{
Index: gcc/testsuite/gcc.c-torture/execute/pr51447.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/pr51447.c (revision 218685)
+++ gcc/testsuite/gcc.c-torture/execute/pr51447.c (working copy)
@@ -14,6 +14,10 @@
main (void)
{
__label__ nonlocal_lab;
+#ifdef __x86_64__
+ void *saved_rbx;
+ asm volatile ("movq %%rbx, %0" : "=r" (saved_rbx) : : );
+#endif
__attribute__((noinline, noclone)) void
bar (void *func)
{
@@ -21,9 +25,15 @@
goto nonlocal_lab;
}
bar (&&nonlocal_lab);
+#ifdef __x86_64__
+ asm volatile ("movq %0, %%rbx" : : "r" (saved_rbx) : "rbx" );
+#endif
return 1;
nonlocal_lab:
if (ptr != &&nonlocal_lab)
abort ();
+#ifdef __x86_64__
+ asm volatile ("movq %0, %%rbx" : : "r" (saved_rbx) : "rbx" );
+#endif
return 0;
}
Index: gcc/testsuite/gcc.dg/cpp/trad/include.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/trad/include.c (revision 218685)
+++ gcc/testsuite/gcc.dg/cpp/trad/include.c (working copy)
@@ -1,11 +1,11 @@
/* Copyright (c) 2002 Free Software Foundation Inc. */
-/* Test that macros are not expanded in the <> quotes of #inlcude. */
+/* Test that macros are not expanded in the <> quotes of #include. */
/* vxWorksCommon.h uses the "#" operator to construct the name of an
include file, thus making the file incompatible with -traditional-cpp.
Newlib uses ## when including stdlib.h as of 2007-09-07. */
-/* { dg-do preprocess { target { { ! vxworks_kernel } && { ! newlib } } } } */
+/* { dg-do preprocess { target { { ! vxworks_kernel } && { ! newlib } && { ! *-*-qnx* } } } } */
#define __STDC__ 1 /* Stop complaints about non-ISO compilers. */
#define stdlib 1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch][testsuite] Fix a few test cases
2014-12-12 19:38 [Patch][testsuite] Fix a few test cases Ryan Mansfield
2014-12-12 21:29 ` Mike Stump
@ 2015-01-05 21:40 ` Jeff Law
1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2015-01-05 21:40 UTC (permalink / raw)
To: Ryan Mansfield, gcc-patches
On 12/12/14 12:38, Ryan Mansfield wrote:
> Hi,
>
> Here are a few test tweaks. In 921202-1.c, if STACK_SIZE is used then
> VLEN will blow the stack with 64bit longs. e.g. if STACK_SIZE == 512K
> then 3 arrays of 32767 longs means at a minimum 767K of stack will be
> used at -O0. In pr51447.c, the rbx global register is clobbering the rbx
> of main's caller, which can cause test case crashes on return.
>
> 2014-12-12 Ryan Mansfield <rmansfield@qnx.com>
>
> * gcc.c-torture/execute/921202-1.c: Adjust VLEN.
> * gcc.c-torture/execute/pr51447.c: Restore rbx for x86-64.
> * gcc.dg/cpp/trad/include.c: Exclude QNX targets.
OK for the trunk. Please install.
Thanks,
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-05 21:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-12 19:38 [Patch][testsuite] Fix a few test cases Ryan Mansfield
2014-12-12 21:29 ` Mike Stump
2014-12-13 1:54 ` Ryan Mansfield
2015-01-05 21:40 ` Jeff Law
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).