From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0626.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::626]) by sourceware.org (Postfix) with ESMTPS id 02AA8385B835; Mon, 23 Mar 2020 18:04:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 02AA8385B835 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Andrea.Corallo@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DlbC9qdxl5Td9GFJZacPbF1zjDnmlMZxCmOfYWToxuY=; b=5KQME9z+F/iGWiNz7tYuoQcHm5ccLi2BjETGJ8fifF9PkwJjy1cqAEMMok+f8BKSCledcUs2uBtQ9mf2lmal+glXDdSLpRskHPHiE/KgRjsTkFqgZ1e4Q3MOlcZXqq+H+0Rl5XwspaUpuf2NToNQ93edqOsqcGs/Igq7wbqKab4= Received: from AM0PR0402CA0034.eurprd04.prod.outlook.com (2603:10a6:208:15::47) by VI1PR08MB4190.eurprd08.prod.outlook.com (2603:10a6:803:eb::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Mon, 23 Mar 2020 18:04:50 +0000 Received: from AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:15:cafe::4f) by AM0PR0402CA0034.outlook.office365.com (2603:10a6:208:15::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Mon, 23 Mar 2020 18:04:49 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT020.mail.protection.outlook.com (10.152.16.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Mon, 23 Mar 2020 18:04:49 +0000 Received: ("Tessian outbound f88013e987c7:v48"); Mon, 23 Mar 2020 18:04:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6a3911f2ab28da0f X-CR-MTA-TID: 64aa7808 Received: from d62ceb8806a0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CEE62758-2AF5-46E7-8D18-C9B3D3F87634.1; Mon, 23 Mar 2020 18:04:44 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d62ceb8806a0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 23 Mar 2020 18:04:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SeytuuLZ8QHeg6dlelHKiLcM6MPyUM+WyPJ0uHWoiuPQa0lcxkA9oW/X7VuEgXtbGs7igKgElqB/AvJ+IXzbN0XY+H0NCnVerYxbVM7s1rkgrPopjj1nsPSOF0h0ZuWDX993tKkmQYOr9xECwEyF0lnh+lbyoGML/g5mIA3nlzM91E4KPlnb1ciRpe2liQYE7m+MosiRzvmSbpYIDT7ar6PmnazRcW9QqJCEK5kUu3yymhOgKB+Z1XZW4jj7mAOGeINXaFWR9TjCXvrLcswGjP4WPhrONbO3ELti0sVr8hUOP7IQEVNWfVKBLQN06zOOK1nHa6vNddWSPbbyCqA/og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DlbC9qdxl5Td9GFJZacPbF1zjDnmlMZxCmOfYWToxuY=; b=ji62/klgH4+0QuCZjksgAPhpITgNDCMNYtiwel6gBQ3d/5za3nd5qqX8wLhKV7HxUwINfkEMqPfEdPyunXS0P10qP526Be/d6lo8uXoDQ+cwgInQg00KaTLaOXVcQIhn4ekNavuJr9f/3etjOGF0wuKTj8Iej2NakWtMcQZwq+4v5nEyw1jD/Oo1X+eV8gSd33VKZYowuedPx2f3mWxrpDNy3yUibCzh7JarHvgiJjLEXA8keHZDSC+2kyUCy111EdbAOyVnKKdnscStH+vq94P/TAR4OjIgxMTGiorRr/DpNV3WbGQBjjhqRe97yf+SclLjZjSffkIFK4sVSSkaGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DlbC9qdxl5Td9GFJZacPbF1zjDnmlMZxCmOfYWToxuY=; b=5KQME9z+F/iGWiNz7tYuoQcHm5ccLi2BjETGJ8fifF9PkwJjy1cqAEMMok+f8BKSCledcUs2uBtQ9mf2lmal+glXDdSLpRskHPHiE/KgRjsTkFqgZ1e4Q3MOlcZXqq+H+0Rl5XwspaUpuf2NToNQ93edqOsqcGs/Igq7wbqKab4= Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; Received: from DB6PR08MB2758.eurprd08.prod.outlook.com (10.170.222.33) by DB6PR08MB2934.eurprd08.prod.outlook.com (10.170.220.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.22; Mon, 23 Mar 2020 18:04:41 +0000 Received: from DB6PR08MB2758.eurprd08.prod.outlook.com ([fe80::109c:ba96:184:6886]) by DB6PR08MB2758.eurprd08.prod.outlook.com ([fe80::109c:ba96:184:6886%5]) with mapi id 15.20.2835.021; Mon, 23 Mar 2020 18:04:41 +0000 From: Andrea Corallo To: David Malcolm Cc: "jit@gcc.gnu.org" , nd , "gcc-patches@gcc.gnu.org" Subject: Re: [committed][gcc] libgccjit: handle long literals in playback::context::new_string_literal References: <878skb263l.fsf@arm.com> <87tv2x9nmi.fsf_-_@arm.com> Date: Mon, 23 Mar 2020 19:04:39 +0100 In-Reply-To: (David Malcolm's message of "Fri, 20 Mar 2020 21:41:05 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: multipart/mixed; boundary="=-=-=" X-ClientProxiedBy: LNXP265CA0088.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::28) To DB6PR08MB2758.eurprd08.prod.outlook.com (2603:10a6:6:1c::33) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from e112547 (217.140.99.251) by LNXP265CA0088.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Mon, 23 Mar 2020 18:04:40 +0000 X-Originating-IP: [217.140.99.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9da668d2-ddda-4816-818a-08d7cf54ade3 X-MS-TrafficTypeDiagnostic: DB6PR08MB2934:|VI1PR08MB4190: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4714;OLM:4714; X-Forefront-PRVS: 0351D213B3 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(376002)(346002)(366004)(136003)(199004)(2906002)(6486002)(81166006)(316002)(8936002)(81156014)(66946007)(66616009)(66556008)(66476007)(235185007)(478600001)(5660300002)(16526019)(26005)(186003)(86362001)(44832011)(6916009)(956004)(2616005)(6496006)(36756003)(54906003)(52116002)(4326008)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR08MB2934; H:DB6PR08MB2758.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: piAEWFivhOQM9ovfqdWwJFncyUH9kBM2/BHbei4Dv3pO2jVRSr8l6wg4UKKn8PKGUS9efxQYpj/6G2Vr8Td4i0F5e7HZJrk8atXDGKbHhs/8VaS/s9tOPY61m/NgjaostTfKH1vJwk0nnh+31hrGEC5RmxoLu1RE8pCqZ1znsSVsEKa2DYNqRXL8rX5tPpun7feo2fg4wb6NLkpI2OlawXgE7lFjrqVh1/MzKY0LIctZ/3msbmZu3+UKs8Amt/7hZHTM9ZnyQqxdISosaGkpuevR4uOs8rBIuXcpJZzmbvkzR88LI2ftcHju9GUK3quclKJkQZ0Mtjo+UO8CMaYUPEx5eiwGiIy3NJQmNOH5FMohBlco7j8ZEEX3tS9OIKMCMTKyzHpqZ4V5OuNbO51x7dCqhU4GTmcrhNrL32qqLQuAhu/4OEh5fWW4WYDSrfxS X-MS-Exchange-AntiSpam-MessageData: +/jovUlTa9AfXdVN2EEZ6/EVRdfMg3rIFVqHZCCdS5xCFBF7H6B6w2TDB7M2yG/PwOJNn7f7MQEmPVAlpQPA/oJ730+yVCz2JIF+7BYNCvDGXuXFHPo+xXrvRMSHDvGeBUC0zCF++hB6u1fIQ6GX6g== X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2934 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(39860400002)(346002)(199004)(46966005)(47076004)(6496006)(4326008)(450100002)(6862004)(8936002)(316002)(235185007)(81156014)(8676002)(36756003)(36906005)(6486002)(5660300002)(81166006)(16526019)(54906003)(186003)(26005)(336012)(2906002)(356004)(66616009)(70206006)(70586007)(478600001)(2616005)(26826003)(956004)(86362001)(44832011); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4190; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1f2b4425-bf38-4bfc-d3bd-08d7cf54a8c0 X-Forefront-PRVS: 0351D213B3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EagqCDfnNCYNZhNpESHK7d6l9XDCb7F7VvAsXZrE0f6XL0CePEsa+djvJ8U7NmeZ4pjMkpiweSddxsL7ZOJW/khjOXOXUQTDJesSUPLo/jKBsUKhv0tlHgJrSn70Nz5XYGhLv95hMiKqcRUvwAybdK0AmKEV+yTCGZ9Umw98zoTdxCROK0y4GNuFMmKDgYvg6fBFjvP8Ago6o4bO7MQZAqxJbe1VbB33Xa5gLTGA3gyU7eon2QG0PLM8eCyZc+ODKcdS7I0vWbJD/72EfsfWQU9wEWSZx48gcuU9Zz4ZOke53yx9kc/ykIK79y1qmKipVKxg0U5UR7CKyguDz7PWqHoXTgxI+OQGTZ8l08UXQ2MXWvZKPbnocXLsugcoqT3a1QzGNVLaILB9P015ZJES4wmrJkFM0Dg9hy5bR4c78iZR0w+c8HqfqQ3LinZTDolocq0eO2NC7pPsLXVobofMTsFcKEtkJjrwNM+wpQlXQm19bgYHL4GJVsqmaYtFPySclJ9R5NWnNUQFhknlximbzg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2020 18:04:49.7014 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9da668d2-ddda-4816-818a-08d7cf54ade3 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4190 X-Spam-Status: No, score=-37.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2020 18:04:55 -0000 --=-=-= Content-Type: text/plain Hi all, attached the final version of the patch for the 200 characters limit for literal strings addressing comments on the missing "testcases" array entry (apologies) and alphabetic order. make check-jit is passing clean. Pushed into trunk. Best Regards Andrea gcc/jit/ChangeLog 2020-03-23 Andrea Corallo * jit-playback.h (gcc::jit::playback::context m_recording_ctxt): Remove m_char_array_type_node field. * jit-playback.c (playback::context::context) Remove m_char_array_type_node from member initializer list. (playback::context::new_string_literal) Fix logic to handle string length > 200. gcc/testsuite/ChangeLog 2020-03-23 Andrea Corallo * jit.dg/all-non-failing-tests.h: Add test-long-string-literal.c. * jit.dg/test-long-string-literal.c: New testcase. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=str.patch diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index 904cc167a0c..074434a9f6b 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -322,7 +322,6 @@ private: auto_vec m_functions; auto_vec m_globals; - tree m_char_array_type_node; tree m_const_char_ptr; /* Source location handling. */ diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index da687002a72..d2c8bb4c154 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -88,7 +88,6 @@ playback::context::context (recording::context *ctxt) : log_user (ctxt->get_logger ()), m_recording_ctxt (ctxt), m_tempdir (NULL), - m_char_array_type_node (NULL), m_const_char_ptr (NULL) { JIT_LOG_SCOPE (get_logger ()); @@ -670,9 +669,14 @@ playback::rvalue * playback::context:: new_string_literal (const char *value) { - tree t_str = build_string (strlen (value), value); - gcc_assert (m_char_array_type_node); - TREE_TYPE (t_str) = m_char_array_type_node; + /* Compare with c-family/c-common.c: fix_string_type. */ + size_t len = strlen (value); + tree i_type = build_index_type (size_int (len)); + tree a_type = build_array_type (char_type_node, i_type); + /* build_string len parameter must include NUL terminator when + building C strings. */ + tree t_str = build_string (len + 1, value); + TREE_TYPE (t_str) = a_type; /* Convert to (const char*), loosely based on c/c-typeck.c: array_to_pointer_conversion, @@ -2701,10 +2705,6 @@ playback::context:: replay () { JIT_LOG_SCOPE (get_logger ()); - /* Adapted from c-common.c:c_common_nodes_and_builtins. */ - tree array_domain_type = build_index_type (size_int (200)); - m_char_array_type_node - = build_array_type (char_type_node, array_domain_type); m_const_char_ptr = build_pointer_type (build_qualified_type (char_type_node, diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h index 0272e6f846f..b2acc74ae95 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -178,6 +178,13 @@ #undef create_code #undef verify_code +/* test-long-string-literal.c */ +#define create_code create_code_long_string_literal +#define verify_code verify_code_long_string_literal +#include "test-long-string-literal.c" +#undef create_code +#undef verify_code + /* test-quadratic.c */ #define create_code create_code_quadratic #define verify_code verify_code_quadratic @@ -342,6 +349,9 @@ const struct testcase testcases[] = { {"long_names", create_code_long_names, verify_code_long_names}, + {"long_string_literal", + create_code_long_string_literal, + verify_code_long_string_literal}, {"quadratic", create_code_quadratic, verify_code_quadratic}, diff --git a/gcc/testsuite/jit.dg/test-long-string-literal.c b/gcc/testsuite/jit.dg/test-long-string-literal.c new file mode 100644 index 00000000000..6caaa781c0b --- /dev/null +++ b/gcc/testsuite/jit.dg/test-long-string-literal.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include + +#include "libgccjit.h" + +#include "harness.h" + +const char very_long_string[] = + "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" + "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" + "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" + "abcabcabcabcabcabcabcabcabcabca"; + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + /* Build the test_fn. */ + gcc_jit_function *f = + gcc_jit_context_new_function ( + ctxt, NULL, + GCC_JIT_FUNCTION_EXPORTED, + gcc_jit_context_get_type(ctxt, + GCC_JIT_TYPE_CONST_CHAR_PTR), + "test_long_string_literal", + 0, NULL, 0); + gcc_jit_block *blk = + gcc_jit_function_new_block (f, "init_block"); + + /* very_long_string is longer than 200 characters to specifically + check that the previous limitation no longer apply. */ + + assert (sizeof (very_long_string) > 200); + gcc_jit_rvalue *res = + gcc_jit_context_new_string_literal (ctxt, very_long_string); + + gcc_jit_block_end_with_return (blk, NULL, res); +} + +void +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) +{ + typedef const char *(*fn_type) (void); + CHECK_NON_NULL (result); + fn_type test_long_string_literal = + (fn_type)gcc_jit_result_get_code (result, "test_long_string_literal"); + CHECK_NON_NULL (test_long_string_literal); + + /* Call the JIT-generated function. */ + const char *str = test_long_string_literal (); + CHECK_NON_NULL (str); + CHECK_VALUE (strcmp (str, very_long_string), 0); +} --=-=-=--