Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217639/?format=api
{ "id": 2217639, "url": "http://patchwork.ozlabs.org/api/patches/2217639/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260330092554.14450-1-chenglulu@loongson.cn/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260330092554.14450-1-chenglulu@loongson.cn>", "list_archive_url": null, "date": "2026-03-30T09:25:54", "name": "LoongArch: Implement TARGET_CHECK_TARGET_CLONE_VERSION.", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "30737621d0f464ef91ef45695b0383605d23e197", "submitter": { "id": 82960, "url": "http://patchwork.ozlabs.org/api/people/82960/?format=api", "name": "Lulu Cheng", "email": "chenglulu@loongson.cn" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260330092554.14450-1-chenglulu@loongson.cn/mbox/", "series": [ { "id": 497989, "url": "http://patchwork.ozlabs.org/api/series/497989/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=497989", "date": "2026-03-30T09:25:54", "name": "LoongArch: Implement TARGET_CHECK_TARGET_CLONE_VERSION.", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/497989/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217639/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217639/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n dmarc=none (p=none dis=none) header.from=loongson.cn", "sourceware.org; spf=pass smtp.mailfrom=loongson.cn", "server2.sourceware.org;\n arc=none smtp.remote-ip=114.242.206.163" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fkm7Q61Dmz1xrn\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 20:25:22 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 8E71E4B920A7\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 09:25:20 +0000 (GMT)", "from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n by sourceware.org (Postfix) with ESMTP id D31174BA2E04\n for <gcc-patches@gcc.gnu.org>; Mon, 30 Mar 2026 09:24:46 +0000 (GMT)", "from loongson.cn (unknown [10.20.4.107])\n by gateway (Coremail) with SMTP id _____8AxjsNRQcppBeofAA--.25672S3;\n Mon, 30 Mar 2026 17:24:33 +0800 (CST)", "from loongson-pc.loongson.cn (unknown [10.20.4.107])\n by front1 (Coremail) with SMTP id qMiowJCxvsJPQcppFqlgAA--.53886S2;\n Mon, 30 Mar 2026 17:24:31 +0800 (CST)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 8E71E4B920A7", "OpenDKIM Filter v2.11.0 sourceware.org D31174BA2E04" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org D31174BA2E04", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org D31174BA2E04", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774862687; cv=none;\n b=uODZp5b9wG30awotUlHcsXREZ4jZklXTCtHN4iIugC4FEX3EiefxMeRSVcSms+OYK2ev+MpcjfxmF9tJgPJgC5ZauqI/qx0+e+c+oQ2JtSMRDsjnolcEzvOQGIc9zzE+mIUqtWlT4frhaBPOE+5jCJ5t/2w+wH5zHf0VsSJgw80=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774862687; c=relaxed/simple;\n bh=lfrzrnDVAeYA7xPJ17An+ax0/t4LnHMYThaYs+8REm8=;\n h=From:To:Subject:Date:Message-Id:MIME-Version;\n b=Ls9fmAHhP1WjPeiIngyiijdfhudTD0y4S0pw3d/P0Hsek7g8/za7TxJWFucgcRv3XWpmNMpxz9sQUXhGwFe0kPrFCIOPJpGaQ5uDtdk0E7Ys8zjdWO8UqUMIiFZDfa10EQ0vSgyeqlc//EoOAxFJCnQi8yBNVBIAnucaATJFuIc=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "From": "Lulu Cheng <chenglulu@loongson.cn>", "To": "gcc-patches@gcc.gnu.org,\n\tchenglulu@loongson.cn", "Cc": "xry111@xry111.site,\n\ti@xen0n.name,\n\txuchenghua@loongson.cn", "Subject": "[PATCH] LoongArch: Implement TARGET_CHECK_TARGET_CLONE_VERSION.", "Date": "Mon, 30 Mar 2026 17:25:54 +0800", "Message-Id": "<20260330092554.14450-1-chenglulu@loongson.cn>", "X-Mailer": "git-send-email 2.20.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-CM-TRANSID": "qMiowJCxvsJPQcppFqlgAA--.53886S2", "X-CM-SenderInfo": "xfkh0wpoxo3qxorr0wxvrqhubq/", "X-Coremail-Antispam": "1Uk129KBj93XoW3Cw4fJ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vjDU0xZFpf9x07UE-erUUUUU=", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "This is to be able to ignore invalid versions to allow some portability\nof code using target_clones attributes.\nAdd warning tests for invalid target_clones versions.\n\ngcc/ChangeLog:\n\n\t* config/loongarch/loongarch-protos.h\n\t(loongarch_parse_fmv_features): Modify parameter type.\n\t* config/loongarch/loongarch-target-attr.cc\n\t(loongarch_parse_fmv_features): Some errors have been\n\tchanged to warnings.\n\t* config/loongarch/loongarch.cc\n\t(loongarch_process_target_version_attr): Update parameters.\n\t(loongarch_check_target_clone_version): Likewise.\n\t(loongarch_option_same_function_versions): Likewise.\n\t(TARGET_CHECK_TARGET_CLONE_VERSION): Define.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.target/loongarch/attr-check-error-message8.c: Removed.\n\t* gcc.target/loongarch/attr-check-error-message9.c: Removed.\n\t* gcc.target/loongarch/attr-check-warning-message1.c: New test.\n\t* gcc.target/loongarch/attr-check-warning-message2.c: New test.\n\t* gcc.target/loongarch/attr-check-warning-message3.c: New test.\n\n---\n gcc/config/loongarch/loongarch-protos.h | 3 +-\n gcc/config/loongarch/loongarch-target-attr.cc | 27 ++++++++++--------\n gcc/config/loongarch/loongarch.cc | 28 +++++++++++++++----\n .../loongarch/attr-check-error-message8.c | 6 ----\n .../loongarch/attr-check-error-message9.c | 6 ----\n .../loongarch/attr-check-warning-message1.c | 7 +++++\n .../loongarch/attr-check-warning-message2.c | 7 +++++\n .../loongarch/attr-check-warning-message3.c | 7 +++++\n 8 files changed, 61 insertions(+), 30 deletions(-)\n delete mode 100644 gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c\n delete mode 100644 gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c\n create mode 100644 gcc/testsuite/gcc.target/loongarch/attr-check-warning-message1.c\n create mode 100644 gcc/testsuite/gcc.target/loongarch/attr-check-warning-message2.c\n create mode 100644 gcc/testsuite/gcc.target/loongarch/attr-check-warning-message3.c", "diff": "diff --git a/gcc/config/loongarch/loongarch-protos.h b/gcc/config/loongarch/loongarch-protos.h\nindex e0c449274a2..11575a15454 100644\n--- a/gcc/config/loongarch/loongarch-protos.h\n+++ b/gcc/config/loongarch/loongarch-protos.h\n@@ -229,7 +229,8 @@ extern void loongarch_register_pragmas (void);\n extern bool loongarch_process_target_attr (tree args, tree fndecl);\n extern rtx loongarch_gen_stepped_int_parallel (unsigned int nelts, int base,\n \t\t\t\t\t int step);\n-extern bool loongarch_parse_fmv_features (tree, string_slice, loongarch_fmv_feature_mask *,\n+extern bool loongarch_parse_fmv_features (location_t, string_slice,\n+\t\t\t\t\t loongarch_fmv_feature_mask *,\n \t\t\t\t\t auto_vec<unsigned int> *);\n extern void get_feature_mask_for_version (tree, loongarch_fmv_feature_mask *,\n \t\t\t\t\t auto_vec<unsigned int> *);\ndiff --git a/gcc/config/loongarch/loongarch-target-attr.cc b/gcc/config/loongarch/loongarch-target-attr.cc\nindex 13ad2ed3731..99e5a3e2214 100644\n--- a/gcc/config/loongarch/loongarch-target-attr.cc\n+++ b/gcc/config/loongarch/loongarch-target-attr.cc\n@@ -524,13 +524,10 @@ loongarch_option_valid_attribute_p (tree fndecl, tree, tree args, int)\n priority calculated by the feature string. */\n \n bool\n-loongarch_parse_fmv_features (tree decl, string_slice str,\n+loongarch_parse_fmv_features (location_t loc, string_slice str,\n \t\t\t loongarch_fmv_feature_mask *feature_mask,\n \t\t\t auto_vec<unsigned int> *feature_priority)\n {\n- location_t loc\n- = decl == NULL ? UNKNOWN_LOCATION : DECL_SOURCE_LOCATION (decl);\n-\n if (feature_mask)\n *feature_mask = 0;\n \n@@ -625,7 +622,7 @@ loongarch_parse_fmv_features (tree decl, string_slice str,\n \t{\n \t string_slice arch_name = attr_str;\n \t string_slice::tokenize (&arch_name, \"=\");\n-\t if (!arch_name.is_valid ())\n+\t if (arch_name.empty ())\n \t {\n \t error_at (loc, \"in attribute %qs you need to set a legal value \"\n \t\t\t\"for \\\"arch\\\"\", attr_str.begin ());\n@@ -659,8 +656,10 @@ loongarch_parse_fmv_features (tree decl, string_slice str,\n \t }\n \t else\n \t {\n-\t error_at (loc, \"in attribute %qs you need to set a legal value \"\n-\t\t\t\"for \\\"arch\\\"\", attr_str.begin ());\n+\t if (loc != UNKNOWN_LOCATION)\n+\t\twarning_at (loc, OPT_Wattributes,\n+\t\t\t \"in attribute %qs you need to set a legal value \"\n+\t\t\t \"for \\\"arch\\\"\", attr_str.begin ());\n \t return false;\n \t }\n \n@@ -681,9 +680,11 @@ loongarch_parse_fmv_features (tree decl, string_slice str,\n \t\t{\n \t\t if (loongarch_attributes[i].feat_mask == 0)\n \t\t {\n-\t\t error_at (loc, \"attribute %qs is not supported in \"\n-\t\t\t\t\"%<target_version%> or %<target_clones%>\",\n-\t\t\t\tattr_str.begin ());\n+\t\t if (loc != UNKNOWN_LOCATION)\n+\t\t\twarning_at (loc, OPT_Wattributes,\n+\t\t\t\t \"attribute %qs is not supported in \"\n+\t\t\t\t \"%<target_version%> or %<target_clones%>\",\n+\t\t\t\t attr_str.begin ());\n \t\t return false;\n \t\t }\n \n@@ -698,8 +699,10 @@ loongarch_parse_fmv_features (tree decl, string_slice str,\n \n \t if (i == num_features - 1)\n \t {\n-\t error_at (loc, \"%qs is not supported in target attribute\",\n-\t\t\tattr_str.begin ());\n+\t if (loc != UNKNOWN_LOCATION)\n+\t\twarning_at (loc, OPT_Wattributes,\n+\t\t\t \"%qs is not supported in target attribute\",\n+\t\t\t attr_str.begin ());\n \t return false;\n \t }\n \t}\ndiff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc\nindex 998cfb9a26a..3dd51029124 100644\n--- a/gcc/config/loongarch/loongarch.cc\n+++ b/gcc/config/loongarch/loongarch.cc\n@@ -11507,7 +11507,7 @@ loongarch_process_target_version_attr (tree args, tree fndecl)\n if (str == \"default\")\n return true;\n \n- if (loongarch_parse_fmv_features (fndecl, str, NULL, NULL) == false)\n+ if (loongarch_parse_fmv_features (loc, str, NULL, NULL) == false)\n return false;\n \n /* Get the attribute string and take out only the option part.\n@@ -11729,8 +11729,22 @@ get_feature_mask_for_version (tree decl,\n \n string_slice version_string\n = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (version_attr)));\n- loongarch_parse_fmv_features (decl, version_string, feature_mask,\n-\t\t\t\tfeature_priority);\n+ loongarch_parse_fmv_features (DECL_SOURCE_LOCATION (decl), version_string,\n+\t\t\t\tfeature_mask, feature_priority);\n+}\n+\n+/* Implement TARGET_CHECK_TARGET_CLONE_VERSION. */\n+\n+bool\n+loongarch_check_target_clone_version (string_slice str, location_t *loc)\n+{\n+ str = str.strip ();\n+\n+ if (str == \"default\")\n+ return true;\n+\n+ return loongarch_parse_fmv_features (loc == NULL ? UNKNOWN_LOCATION : *loc,\n+\t\t\t\t str, NULL, NULL);\n }\n \n /* This adds a condition to the basic_block NEW_BB in function FUNCTION_DECL\n@@ -12088,9 +12102,9 @@ loongarch_option_same_function_versions (string_slice str1, const_tree,\n {\n loongarch_fmv_feature_mask feature_mask1;\n loongarch_fmv_feature_mask feature_mask2;\n- loongarch_parse_fmv_features (NULL, str1,\n+ loongarch_parse_fmv_features (UNKNOWN_LOCATION, str1,\n \t\t\t\t&feature_mask1, NULL);\n- loongarch_parse_fmv_features (NULL, str2,\n+ loongarch_parse_fmv_features (UNKNOWN_LOCATION, str2,\n \t\t\t\t&feature_mask2, NULL);\n \n return feature_mask1 == feature_mask2;\n@@ -12395,6 +12409,10 @@ loongarch_option_same_function_versions (string_slice str1, const_tree,\n #define TARGET_MANGLE_DECL_ASSEMBLER_NAME \\\n loongarch_mangle_decl_assembler_name\n \n+#undef TARGET_CHECK_TARGET_CLONE_VERSION\n+#define TARGET_CHECK_TARGET_CLONE_VERSION \\\n+ loongarch_check_target_clone_version\n+\n #undef TARGET_GENERATE_VERSION_DISPATCHER_BODY\n #define TARGET_GENERATE_VERSION_DISPATCHER_BODY \\\n loongarch_generate_version_dispatcher_body\ndiff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c\ndeleted file mode 100644\nindex f27712bf5df..00000000000\n--- a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c\n+++ /dev/null\n@@ -1,6 +0,0 @@\n-/* { dg-do compile } */\n-/* { dg-options \"-O2 -Wno-attributes\" } */\n-\n-__attribute__ ((target_clones (\"default\",\"cmodel=normal\"))) void\n-test (void)\t/* { dg-error \"attribute \\\\\\'cmodel=normal\\\\\\' is not supported in \\\\\\'target_version\\\\\\' or \\\\\\'target_clones\\\\\\'\" } */\n-{}\ndiff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c\ndeleted file mode 100644\nindex 4e02579942f..00000000000\n--- a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c\n+++ /dev/null\n@@ -1,6 +0,0 @@\n-/* { dg-do compile } */\n-/* { dg-options \"-O2 -Wno-attributes\" } */\n-\n-__attribute__ ((target_clones (\"default\",\"123456\"))) void\n-test (void)\t/* { dg-error \"\\\\\\'123456\\\\\\' is not supported in target attribute\" } */\n-{}\ndiff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message1.c b/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message1.c\nnew file mode 100644\nindex 00000000000..a5da86a4f59\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message1.c\n@@ -0,0 +1,7 @@\n+/* { dg-do compile } */\n+/* { dg-require-ifunc \"\" } */\n+/* { dg-options \"-O0\" } */\n+\n+__attribute__ ((target_clones (\"default\",\"123456\"))) void\n+test (void)\t/* { dg-warning \"\\\\\\'123456\\\\\\' is not supported in target attribute\" } */\n+{}\ndiff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message2.c b/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message2.c\nnew file mode 100644\nindex 00000000000..117beddc619\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message2.c\n@@ -0,0 +1,7 @@\n+/* { dg-do compile } */\n+/* { dg-require-ifunc \"\" } */\n+/* { dg-options \"-O0\" } */\n+\n+__attribute__ ((target_clones (\"default\",\"arch=123456\"))) void\n+test (void)\t/* { dg-warning \"in attribute \\\\\\'arch=123456\\\\\\' you need to set a legal value for \\\\\\\"arch\\\\\\\"\" } */\n+{}\ndiff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message3.c b/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message3.c\nnew file mode 100644\nindex 00000000000..f1339f9fea6\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-warning-message3.c\n@@ -0,0 +1,7 @@\n+/* { dg-do compile } */\n+/* { dg-require-ifunc \"\" } */\n+/* { dg-options \"-O0\" } */\n+\n+__attribute__ ((target_clones (\"default\",\"cmodel=normal\"))) void\n+test (void)\t/* { dg-warning \"attribute \\\\\\'cmodel=normal\\\\\\' is not supported in \\\\\\'target_version\\\\\\' or \\\\\\'target_clones\\\\\\'\" } */\n+{}\n", "prefixes": [] }