From patchwork Tue Jul 7 07:53:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 492080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 EF5501402BA for ; Tue, 7 Jul 2015 17:54:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=NdciE4g4; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=yJhe+sQjfKHtilOif0m05WHKpO2qtAnZa27+BGLuJl0z66 jo41LBL7gTk0SO9/sqJQKuZQx9GmKoLiQN5YfUSUMR7A4VSPxhta5mXMGWDWLsyb CXvqXZ+yyeNfY2XjABvG4meWzh2KG1pFYekdNJh2ZDz5UZbL/Dc+2/u6TLSLU= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=yg3ecBLQOq4GMS6Ib3+R/UnlDF0=; b=NdciE4g4RrH/cVMpbZxL aslJtXYnZRwacS6sHVdiDuVyhUk3vb+HIaCROBYFCgjs5VzLmr2XzsFvbrM07b/6 RA7rcPEoKmauJxz1+V4xP9gkxmgE6rqS84XtuK+mkrMJOjQ7C5JMtq6rluE563zC ar5IDzNhAc2bljjJ3KiGXCo= Received: (qmail 22060 invoked by alias); 7 Jul 2015 07:54:04 -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 20031 invoked by uid 89); 7 Jul 2015 07:54:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 07 Jul 2015 07:54:01 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55978) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZCNhX-00057J-Fr for gcc-patches@gnu.org; Tue, 07 Jul 2015 03:53:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCNhR-00011X-P7 for gcc-patches@gnu.org; Tue, 07 Jul 2015 03:53:58 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:62803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCNhR-00010t-Jb for gcc-patches@gnu.org; Tue, 07 Jul 2015 03:53:53 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZCNhP-0001jc-J1 from Tom_deVries@mentor.com for gcc-patches@gnu.org; Tue, 07 Jul 2015 00:53:51 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Tue, 7 Jul 2015 08:53:26 +0100 Message-ID: <559B8565.6030806@mentor.com> Date: Tue, 7 Jul 2015 09:53:09 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "gcc-patches@gnu.org" Subject: [patch, driver] Ignore -ftree-parallelize-loops={0,1} X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Hi, currently, we have these spec strings in gcc/gcc.c involving ftree-parallelize-loops: ... %{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %{fopenacc|fopenmp|ftree-parallelize-loops=*:-pthread}" ... Actually, ftree-parallelize-loops={0,1} means that no parallelization is done, but these spec strings still get activated for these values. Attached patch fixes that, by introducing a spec function gt (short for greather than), and using it in the spec lines. [ I've also tried this approach using the already existing spec function version-compare: ... %{fopenacc|fopenmp:%:include(libgomp.spec)%(link_gomp)} %:version-compare(>= 2 ftree-parallelize-loops= %:include(libgomp.spec)%(link_gomp)) ... But that didn't work out. The function evaluation mechanism evaluates the arguments before testing the function, so we evaluate '%:include(libgomp.spec)' unconditionally. The gcc build breaks on the first xgcc invocation with linking due to a missing libgomp.spec. ] Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom Ignore -ftree-parallelize-loops={0,1} using gt --- gcc/gcc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/gcc/gcc.c b/gcc/gcc.c index 0f29b78..34fb437 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -274,6 +274,7 @@ static const char *compare_debug_self_opt_spec_function (int, const char **); static const char *compare_debug_auxbase_opt_spec_function (int, const char **); static const char *pass_through_libs_spec_func (int, const char **); static const char *replace_extension_spec_func (int, const char **); +static const char *greater_than_spec_func (int, const char **); static char *convert_white_space (char *); /* The Specs Language @@ -881,7 +882,7 @@ proper position among the other output files. */ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \ %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\ " CHKP_SPEC " \ - %{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ + %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*} 1):%:include(libgomp.spec)%(link_gomp)} \ %{fcilkplus:%:include(libcilkrts.spec)%(link_cilkrts)}\ %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\ %(mflib) " STACK_SPLIT_SPEC "\ @@ -1042,7 +1043,8 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS; /* Linking to libgomp implies pthreads. This is particularly important for targets that use different start files and suchlike. */ #ifndef GOMP_SELF_SPECS -#define GOMP_SELF_SPECS "%{fopenacc|fopenmp|ftree-parallelize-loops=*: " \ +#define GOMP_SELF_SPECS \ + "%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*} 1): " \ "-pthread}" #endif @@ -1482,6 +1484,7 @@ static const struct spec_function static_spec_functions[] = { "compare-debug-auxbase-opt", compare_debug_auxbase_opt_spec_function }, { "pass-through-libs", pass_through_libs_spec_func }, { "replace-extension", replace_extension_spec_func }, + { "gt", greater_than_spec_func }, #ifdef EXTRA_SPEC_FUNCTIONS EXTRA_SPEC_FUNCTIONS #endif @@ -9428,6 +9431,47 @@ replace_extension_spec_func (int argc, const char **argv) return result; } +/* Returns "" if the n in ARGV[1] == -opt= is greater than ARGV[2]. + Otherwise, return NULL. */ + +static const char * +greater_than_spec_func (int argc, const char **argv) +{ + char *converted; + + if (argc == 1) + return NULL; + + gcc_assert (argc == 3); + gcc_assert (argv[0][0] == '-'); + gcc_assert (argv[0][1] == '\0'); + + /* Point p to in in -opt=. */ + const char *p = argv[1]; + while (true) + { + char c = *p; + if (c == '\0') + gcc_unreachable (); + + ++p; + + if (c == '=') + break; + } + + long arg = strtol (p, &converted, 10); + gcc_assert (converted != p); + + long lim = strtol (argv[2], &converted, 10); + gcc_assert (converted != argv[2]); + + if (arg > lim) + return ""; + + return NULL; +} + /* Insert backslash before spaces in ORIG (usually a file path), to avoid being broken by spec parser. -- 1.9.1