From 1ce521ece9a514dd8c5a3baa6e66bab928fd5e7c Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 16 Aug 2019 03:38:36 +0000 Subject: [PATCH] use __builtin_alloca, drop non-standard alloca.h Since alloca.h is not ISO C, most of our alloca-using tests seem to rely on __builtin_alloca instead of including the header and calling alloca. This patch extends this practice to some of the exceptions I found in gcc.target, marking them as requiring a functional alloca while at that. for gcc/testsuite/ChangeLog * gcc.target/arc/interrupt-6.c: Use __builtin_alloca, require effective target support for alloca, drop include of alloca.h. * gcc.target/i386/pr80969-3.c: Likewise. * gcc.target/sparc/setjmp-1.c: Likewise. * gcc.target/x86_64/abi/ms-sysv/gen.cc: Likewise. * gcc.target/x86_64/abi/ms-sysv/ms-sysv.c: Likewise. From-SVN: r274558 --- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.target/arc/interrupt-6.c | 5 ++--- gcc/testsuite/gcc.target/i386/pr80969-3.c | 5 ++--- gcc/testsuite/gcc.target/sparc/setjmp-1.c | 4 ++-- gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/gen.cc | 2 +- gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55c59822dde..055ff045e0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2019-08-16 Alexandre Oliva + * gcc.target/arc/interrupt-6.c: Use __builtin_alloca, require + effective target support for alloca, drop include of alloca.h. + * gcc.target/i386/pr80969-3.c: Likewise. + * gcc.target/sparc/setjmp-1.c: Likewise. + * gcc.target/x86_64/abi/ms-sysv/gen.cc: Likewise. + * gcc.target/x86_64/abi/ms-sysv/ms-sysv.c: Likewise. + * gcc.misc-tests/options.exp: Match /ld and -ld besides /collect2. diff --git a/gcc/testsuite/gcc.target/arc/interrupt-6.c b/gcc/testsuite/gcc.target/arc/interrupt-6.c index d82bd67edd8..9cb0565f55c 100644 --- a/gcc/testsuite/gcc.target/arc/interrupt-6.c +++ b/gcc/testsuite/gcc.target/arc/interrupt-6.c @@ -1,8 +1,7 @@ /* { dg-do compile } */ /* { dg-skip-if "Not available for ARCv1" { arc700 || arc6xx } } */ /* { dg-options "-O2 -mirq-ctrl-saved=r0-ilink" } */ - -#include +/* { dg-require-effective-target alloca } */ /* Check if ilink is recognized. Check how FP and BLINK are saved. BLINK is saved last on the stack because the IRQ autosave will do @@ -14,7 +13,7 @@ extern int bar (void *); void __attribute__ ((interrupt("ilink"))) foo(void) { - int *p = alloca (10); + int *p = __builtin_alloca (10); bar (p); } /* { dg-final { scan-assembler-not ".*fp,\\\[sp" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr80969-3.c b/gcc/testsuite/gcc.target/i386/pr80969-3.c index d902a771cc8..318e06cd94c 100644 --- a/gcc/testsuite/gcc.target/i386/pr80969-3.c +++ b/gcc/testsuite/gcc.target/i386/pr80969-3.c @@ -2,11 +2,10 @@ /* { dg-do compile { target { { ! x32 } && { ! avx512f_runtime } } } } */ /* { dg-options "-Ofast -mabi=ms -mavx512f" } */ /* { dg-require-effective-target avx512f } */ +/* { dg-require-effective-target alloca } */ /* Test with alloca (and DRAP). */ -#include - int a[56]; volatile int b = -12345; volatile const int d = 42; @@ -19,7 +18,7 @@ void (*volatile const foo_noinfo)(int *, int, int) = foo; int main (int argc, char *argv[]) { int c; - int *e = alloca (d); + int *e = __builtin_alloca (d); foo_noinfo (e, d, 0); for (; b; b++) { c = b; diff --git a/gcc/testsuite/gcc.target/sparc/setjmp-1.c b/gcc/testsuite/gcc.target/sparc/setjmp-1.c index d0fecb36327..699d7f7b8ff 100644 --- a/gcc/testsuite/gcc.target/sparc/setjmp-1.c +++ b/gcc/testsuite/gcc.target/sparc/setjmp-1.c @@ -4,9 +4,9 @@ /* { dg-do run { target *-*-solaris2.* *-*-linux* *-*-*bsd* } } */ /* { dg-require-effective-target fpic } */ /* { dg-options "-fPIC" } */ +/* { dg-require-effective-target alloca } */ #include -#include #include #include #include @@ -26,7 +26,7 @@ int main (void) { setjmp (jb); - char *p = alloca (256); + char *p = __builtin_alloca (256); memset (p, 0, 256); sprintf (p, "%d\n", foo); diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/gen.cc b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/gen.cc index 701531480f6..818a8875a6d 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/gen.cc +++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/gen.cc @@ -291,7 +291,7 @@ void fn::print_def (ostream &out) const if (get_msabi () && get_alloca ()) { const char *size_str = m_args.empty () ? "42" : "a"; - out << " void *alloca_mem = alloca (8 + " << size_str << ");" << endl + out << " void *alloca_mem = __builtin_alloca (8 + " << size_str << ");" << endl << " *(long*)alloca_mem = FLAG_ALLOCA;" << endl; } if (get_msabi () && get_varargs ()) diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c index 5fdd1e20674..abfcee6f56a 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c +++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c @@ -49,6 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* { dg-do run } */ /* { dg-additional-sources "do-test.S" } */ /* { dg-additional-options "-Wall" } */ +/* { dg-require-effective-target alloca } */ #include #include @@ -56,7 +57,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include #include #include -#include #include #include #include -- 2.30.2