From patchwork Thu Aug 15 08:17:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1147454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507012-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QDcAK2a3"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 468K836pp6z9sN6 for ; Thu, 15 Aug 2019 18:17:54 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=BUWRGTDP7e6hfHRz nkutIg1RTe9GJXvyRA7dcNyEXV15pNmue6oQrmY9Q53uDwdrLosdgMslb3IWDdw2 0t3UtKnx8U0VJDOwwCiLHc/N2833DhVkh+DIlisLO/TzF2d8IkOSIMwCKcTi9Pa/ sIAhXGFmgqHJlIFQ3xpgc1PDybI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=eS0mmJe9XILSI17/D0fj4h 08VHY=; b=QDcAK2a355Ep4jwLBJolrLCatI0hziKeeWhHAtIkbFml9QCcY4waLn PQ1/hx13P4XopxMgfqx+RgbNn0xnAtl4JNjBy3XJk89x6AECh1g7ZQTxMXdV8GGH 1QJwJUHe7JTOObcuIVGwQjg0nZP404C0YWLJASzJj9XBJxefPci4k= Received: (qmail 38861 invoked by alias); 15 Aug 2019 08:17:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 38852 invoked by uid 89); 15 Aug 2019 08:17:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=long* X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Aug 2019 08:17:45 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 270FD116540; Thu, 15 Aug 2019 04:17:44 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5C7qux1T8m4H; Thu, 15 Aug 2019 04:17:44 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id E057211682B; Thu, 15 Aug 2019 04:17:43 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id x7F8HXUn036366 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 15 Aug 2019 05:17:33 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Mike Stump Subject: use __builtin_alloca, drop non-standard alloca.h Date: Thu, 15 Aug 2019 05:17:33 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 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. Tested on x86_64-linux-gnu, and manually compile-tested the non-x86 tests. Ok to install? 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. --- 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.target/x86_64/abi/ms-sysv/ms-sysv.c | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/gcc/testsuite/gcc.target/arc/interrupt-6.c b/gcc/testsuite/gcc.target/arc/interrupt-6.c index d82bd67edd83..9cb0565f55c9 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 d902a771cc8f..318e06cd94c6 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 d0fecb363270..699d7f7b8ff4 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 701531480f62..818a8875a6dd 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 5fdd1e20674b..abfcee6f56a4 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