Commit 1ce521ec by Alexandre Oliva Committed by Alexandre Oliva

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
parent 2bfd0045
2019-08-16 Alexandre Oliva <oliva@adacore.com> 2019-08-16 Alexandre Oliva <oliva@adacore.com>
* 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 * gcc.misc-tests/options.exp: Match /ld and -ld besides
/collect2. /collect2.
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "Not available for ARCv1" { arc700 || arc6xx } } */ /* { dg-skip-if "Not available for ARCv1" { arc700 || arc6xx } } */
/* { dg-options "-O2 -mirq-ctrl-saved=r0-ilink" } */ /* { dg-options "-O2 -mirq-ctrl-saved=r0-ilink" } */
/* { dg-require-effective-target alloca } */
#include <alloca.h>
/* Check if ilink is recognized. Check how FP and BLINK are saved. /* 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 BLINK is saved last on the stack because the IRQ autosave will do
...@@ -14,7 +13,7 @@ extern int bar (void *); ...@@ -14,7 +13,7 @@ extern int bar (void *);
void __attribute__ ((interrupt("ilink"))) void __attribute__ ((interrupt("ilink")))
foo(void) foo(void)
{ {
int *p = alloca (10); int *p = __builtin_alloca (10);
bar (p); bar (p);
} }
/* { dg-final { scan-assembler-not ".*fp,\\\[sp" } } */ /* { dg-final { scan-assembler-not ".*fp,\\\[sp" } } */
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
/* { dg-do compile { target { { ! x32 } && { ! avx512f_runtime } } } } */ /* { dg-do compile { target { { ! x32 } && { ! avx512f_runtime } } } } */
/* { dg-options "-Ofast -mabi=ms -mavx512f" } */ /* { dg-options "-Ofast -mabi=ms -mavx512f" } */
/* { dg-require-effective-target avx512f } */ /* { dg-require-effective-target avx512f } */
/* { dg-require-effective-target alloca } */
/* Test with alloca (and DRAP). */ /* Test with alloca (and DRAP). */
#include <alloca.h>
int a[56]; int a[56];
volatile int b = -12345; volatile int b = -12345;
volatile const int d = 42; volatile const int d = 42;
...@@ -19,7 +18,7 @@ void (*volatile const foo_noinfo)(int *, int, int) = foo; ...@@ -19,7 +18,7 @@ void (*volatile const foo_noinfo)(int *, int, int) = foo;
int main (int argc, char *argv[]) { int main (int argc, char *argv[]) {
int c; int c;
int *e = alloca (d); int *e = __builtin_alloca (d);
foo_noinfo (e, d, 0); foo_noinfo (e, d, 0);
for (; b; b++) { for (; b; b++) {
c = b; c = b;
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
/* { dg-do run { target *-*-solaris2.* *-*-linux* *-*-*bsd* } } */ /* { dg-do run { target *-*-solaris2.* *-*-linux* *-*-*bsd* } } */
/* { dg-require-effective-target fpic } */ /* { dg-require-effective-target fpic } */
/* { dg-options "-fPIC" } */ /* { dg-options "-fPIC" } */
/* { dg-require-effective-target alloca } */
#include <stdio.h> #include <stdio.h>
#include <alloca.h>
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -26,7 +26,7 @@ int main (void) ...@@ -26,7 +26,7 @@ int main (void)
{ {
setjmp (jb); setjmp (jb);
char *p = alloca (256); char *p = __builtin_alloca (256);
memset (p, 0, 256); memset (p, 0, 256);
sprintf (p, "%d\n", foo); sprintf (p, "%d\n", foo);
......
...@@ -291,7 +291,7 @@ void fn::print_def (ostream &out) const ...@@ -291,7 +291,7 @@ void fn::print_def (ostream &out) const
if (get_msabi () && get_alloca ()) if (get_msabi () && get_alloca ())
{ {
const char *size_str = m_args.empty () ? "42" : "a"; 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; << " *(long*)alloca_mem = FLAG_ALLOCA;" << endl;
} }
if (get_msabi () && get_varargs ()) if (get_msabi () && get_varargs ())
......
...@@ -49,6 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -49,6 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* { dg-do run } */ /* { dg-do run } */
/* { dg-additional-sources "do-test.S" } */ /* { dg-additional-sources "do-test.S" } */
/* { dg-additional-options "-Wall" } */ /* { dg-additional-options "-Wall" } */
/* { dg-require-effective-target alloca } */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
...@@ -56,7 +57,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -56,7 +57,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <alloca.h>
#include <stdarg.h> #include <stdarg.h>
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment