From patchwork Thu Apr 11 08:37:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1083761 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-499092-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="r33wNhLf"; 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 44fvYJ3YLgz9s71 for ; Thu, 11 Apr 2019 18:37: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 :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=niSU0eviTEQco9fz7/IngKnpSxc99mApwTwxd+KSGrgAoxJmvctz4 1OeEe3HgSVHYaA3kk9YBV+KSYzyqFcy3kvQiZpw10YgOc9hrIAXccMqwNouOnu1H rjH7tgjWZb8myk7tEwqeiDyeBblub7tbd9/MVRBkiQDRXpp0aAN0xQ= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=/3pbPuoYVelaefLBc06Evs/LeEk=; b=r33wNhLfBJBS0zv2sNIU iav/XYC4jSSS+pSaMd+nJbHmcW5IXO3vaSbNnG+9amG6RWCJcOR9AeqhGsqGC6ml qAp+s4NYrZi6KBTR9099/lX3yX0tuyksrOkLtduZwtW2ZL9M05Tyt69NkJKj319t NtdGGSHAZU2/q66KxEZyAUI= Received: (qmail 126284 invoked by alias); 11 Apr 2019 08:37:46 -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 126272 invoked by uid 89); 11 Apr 2019 08:37:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:dgrequ, sk:dg-requ, H*MI:2641, dgerror X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Apr 2019 08:37:44 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 82867AD65 for ; Thu, 11 Apr 2019 08:37:42 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Handle multiple 'default' in target attribute (PR middle-end/89970). To: gcc-patches@gcc.gnu.org Message-ID: <80b9b4d6-2641-d726-2925-03053b5f231f@suse.cz> Date: Thu, 11 Apr 2019 10:37:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi. The patch is catching duplicate 'default' values in target attribute. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: 2019-04-10 Martin Liska PR middle-end/89970 * multiple_target.c (create_dispatcher_calls): Wrap ifunc in error message. (separate_attrs): Handle multiple 'default's. (expand_target_clones): Rework error handling code. gcc/testsuite/ChangeLog: 2019-04-10 Martin Liska PR middle-end/89970 * gcc.target/i386/mvc15.c: New test. * gcc.target/i386/mvc3.c: Quote target in error pattern. * gcc.target/i386/mvc4.c: Remove duplicit 'default'. --- gcc/multiple_target.c | 38 ++++++++++++++++++--------- gcc/testsuite/gcc.target/i386/mvc15.c | 11 ++++++++ gcc/testsuite/gcc.target/i386/mvc3.c | 2 +- gcc/testsuite/gcc.target/i386/mvc4.c | 2 +- 4 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/mvc15.c diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c index fd983cc4ad9..99dc9da44f5 100644 --- a/gcc/multiple_target.c +++ b/gcc/multiple_target.c @@ -73,7 +73,7 @@ create_dispatcher_calls (struct cgraph_node *node) if (!targetm.has_ifunc_p ()) { error_at (DECL_SOURCE_LOCATION (node->decl), - "the call requires ifunc, which is not" + "the call requires %, which is not" " supported by this target"); return; } @@ -235,8 +235,10 @@ get_attr_str (tree arglist, char *attr_str) } /* Return number of attributes separated by comma and put them into ARGS. - If there is no DEFAULT attribute return -1. If there is an empty - string in attribute return -2. */ + If there is no DEFAULT attribute return -1. + If there is an empty string in attribute return -2. + If there are multiple DEFAULT attributes return -3. + */ static int separate_attrs (char *attr_str, char **attrs, int attrnum) @@ -256,6 +258,8 @@ separate_attrs (char *attr_str, char **attrs, int attrnum) } if (default_count == 0) return -1; + else if (default_count > 1) + return -3; else if (i + default_count < attrnum) return -2; @@ -347,8 +351,7 @@ expand_target_clones (struct cgraph_node *node, bool definition) if (attr_len == -1) { warning_at (DECL_SOURCE_LOCATION (node->decl), - 0, - "single % attribute is ignored"); + 0, "single % attribute is ignored"); return false; } @@ -374,21 +377,30 @@ expand_target_clones (struct cgraph_node *node, bool definition) char **attrs = XNEWVEC (char *, attrnum); attrnum = separate_attrs (attr_str, attrs, attrnum); - if (attrnum == -1) + switch (attrnum) { + case -1: error_at (DECL_SOURCE_LOCATION (node->decl), - "default target was not set"); - XDELETEVEC (attrs); - XDELETEVEC (attr_str); - return false; - } - else if (attrnum == -2) - { + "% target was not set"); + break; + case -2: error_at (DECL_SOURCE_LOCATION (node->decl), "an empty string cannot be in % attribute"); + break; + case -3: + error_at (DECL_SOURCE_LOCATION (node->decl), + "multiple % targets were set"); + break; + default: + break; + } + + if (attrnum < 0) + { XDELETEVEC (attrs); XDELETEVEC (attr_str); return false; + } cgraph_function_version_info *decl1_v = NULL; diff --git a/gcc/testsuite/gcc.target/i386/mvc15.c b/gcc/testsuite/gcc.target/i386/mvc15.c new file mode 100644 index 00000000000..955aa1e9fe8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mvc15.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ + +__attribute__((target_clones("default", "default"))) +int foo (); /* { dg-error "multiple 'default' targets were set" } */ + +int +bar () +{ + return foo(); +} diff --git a/gcc/testsuite/gcc.target/i386/mvc3.c b/gcc/testsuite/gcc.target/i386/mvc3.c index 1c7755fabbe..f14fc02694c 100644 --- a/gcc/testsuite/gcc.target/i386/mvc3.c +++ b/gcc/testsuite/gcc.target/i386/mvc3.c @@ -2,7 +2,7 @@ /* { dg-require-ifunc "" } */ __attribute__((target_clones("avx","arch=slm","arch=core-avx2"))) -int foo (); /* { dg-error "default target was not set" } */ +int foo (); /* { dg-error "'default' target was not set" } */ int bar () diff --git a/gcc/testsuite/gcc.target/i386/mvc4.c b/gcc/testsuite/gcc.target/i386/mvc4.c index 91293c34cca..1b9b0b4f174 100644 --- a/gcc/testsuite/gcc.target/i386/mvc4.c +++ b/gcc/testsuite/gcc.target/i386/mvc4.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-require-ifunc "" } */ -__attribute__((target_clones("default","avx","default"))) +__attribute__((target_clones("default","avx"))) int foo () {