From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150072.outbound.protection.outlook.com [40.107.15.72]) by sourceware.org (Postfix) with ESMTPS id 9B66E3953042; Mon, 9 Mar 2020 22:20:32 +0000 (GMT) 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=MpWRWHhEl5mn+3wfdg+YfSoMEkBEEBmKHshNQdjuzME=; b=EeqoKvpLJ+nYaTfdBFHVsZXrBUVC1WBCMmVmAp+jzGxJ3ylRBxnXwf0ZwrLDKlKoHT6OCavmy8HyhbKBqxRqu0gvUWOLvQEUqHxyLDn2fPB2twGY7p4yIlYuLANo0kEj/+i9QzQeLYoMPbzqaPy2181pvYjz/rJ7qC83Q26OriE= Received: from DB6PR0202CA0008.eurprd02.prod.outlook.com (2603:10a6:4:29::18) by HE1PR0802MB2299.eurprd08.prod.outlook.com (2603:10a6:3:c0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.16; Mon, 9 Mar 2020 22:20:30 +0000 Received: from DB5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::d5) by DB6PR0202CA0008.outlook.office365.com (2603:10a6:4:29::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.16 via Frontend Transport; Mon, 9 Mar 2020 22:20:30 +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 DB5EUR03FT014.mail.protection.outlook.com (10.152.20.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11 via Frontend Transport; Mon, 9 Mar 2020 22:20:30 +0000 Received: ("Tessian outbound da94dc68d1bb:v42"); Mon, 09 Mar 2020 22:20:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0adfa9b83faf9247 X-CR-MTA-TID: 64aa7808 Received: from d026f4ff31df.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 24D1A99A-6BB0-42AD-9D61-6E9D7CB007F6.1; Mon, 09 Mar 2020 22:20:24 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d026f4ff31df.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 09 Mar 2020 22:20:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bKjqs9HnrjLFTsebUiJvRR/v+Ta00WQRXmVXdUverlk4F3/TypWuRoHav9HzEftG1xDvD+PW+2yuWoxOUuIepnllyL9HVK/heylfS5aDrlqHcu7sQ/krbZWBttu8zeOJB3222HDRyuilBZo3PBpX1FRMhtFSMXhkle/v5jji0RLO4RAhhAjxKYjBSUjE6e9GbvrHxNS1ehp6tcG1Oye+9EWb9n2D1+8s2FB10fyt3RFVV+pm2AsweyqF9Mc7QUUb0hAimLJpDWExFhJjpr5j3rWdbZBWnZ8EYZdlPFQbQS29Tyy0jOtO2Mycm3/L70MBD2dng+c5uHBHBWppYK316g== 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=MpWRWHhEl5mn+3wfdg+YfSoMEkBEEBmKHshNQdjuzME=; b=i9WDN05c8JT1yFwezZ8qqDGoLTx7umBbjM8s4wBU8sdUoaI5xbDwqJZhsn42qqkGGvezn4TUCwghkIcntGmm0uCATC//AqwsiRt0PzKQIOcR7wnm+YdpV5Ig8XW/B6CWF6z2KPXtEoxQAcHRsM4Ag1lhzUFXnT3grbJpfdv3myNfWqwhNyxjpkUG5sk4RnWiSAtBJ5kTZ6oybfu1qeBjoGdG99Y+GRmOG1oWsp13NsHv0KFGcJrbPfwfevSmQ8Skif6WrTUPS4XuUDKJFL+4AU11F91VcwZ7exigSI7V9FsRL3LfQ4fT3Er51hMYaUeh9jYyOeRt2KCv9gP1AOaZ3w== 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=MpWRWHhEl5mn+3wfdg+YfSoMEkBEEBmKHshNQdjuzME=; b=EeqoKvpLJ+nYaTfdBFHVsZXrBUVC1WBCMmVmAp+jzGxJ3ylRBxnXwf0ZwrLDKlKoHT6OCavmy8HyhbKBqxRqu0gvUWOLvQEUqHxyLDn2fPB2twGY7p4yIlYuLANo0kEj/+i9QzQeLYoMPbzqaPy2181pvYjz/rJ7qC83Q26OriE= Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; Received: from VI1PR08MB2765.eurprd08.prod.outlook.com (10.170.236.32) by VI1PR08MB4256.eurprd08.prod.outlook.com (20.179.24.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.17; Mon, 9 Mar 2020 22:20:23 +0000 Received: from VI1PR08MB2765.eurprd08.prod.outlook.com ([fe80::8413:fc03:8c5a:5ed6]) by VI1PR08MB2765.eurprd08.prod.outlook.com ([fe80::8413:fc03:8c5a:5ed6%3]) with mapi id 15.20.2793.013; Mon, 9 Mar 2020 22:20:23 +0000 From: Andrea Corallo To: David Malcolm Cc: "jit@gcc.gnu.org" , nd , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH v2][gcc] libgccjit: handle long literals in playback::context::new_string_literal References: <878skb263l.fsf@arm.com> Date: Mon, 09 Mar 2020 22:20:21 +0000 In-Reply-To: <878skb263l.fsf@arm.com> (Andrea Corallo's message of "Sat, 07 Mar 2020 21:43:58 +0000") Message-ID: <87tv2x9nmi.fsf_-_@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: multipart/mixed; boundary="=-=-=" X-ClientProxiedBy: LO2P265CA0192.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::36) To VI1PR08MB2765.eurprd08.prod.outlook.com (2603:10a6:802:18::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from krcb (217.140.106.53) by LO2P265CA0192.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.16 via Frontend Transport; Mon, 9 Mar 2020 22:20:22 +0000 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8eaaae16-52c4-49f8-5020-08d7c47813b7 X-MS-TrafficTypeDiagnostic: VI1PR08MB4256:|HE1PR0802MB2299: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4714;OLM:4714; X-Forefront-PRVS: 0337AFFE9A X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(396003)(136003)(346002)(366004)(376002)(199004)(189003)(81166006)(66556008)(81156014)(66476007)(8936002)(16526019)(26005)(186003)(86362001)(66616009)(66946007)(8676002)(36756003)(6496006)(52116002)(6486002)(2906002)(54906003)(956004)(316002)(2616005)(4326008)(478600001)(5660300002)(6916009)(44832011)(235185007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4256; H:VI1PR08MB2765.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: 94x3xudf2gLWoFEI4Mfbgk1MzEZwIaSo2ElR8RYod9UMGAYHAif4blRpBZ2jHvYk9IcOjFt3nF6XLCjUBE3tlCFhSCvAz6KFdCfKRAffx4K6AgjvobU9qluDSVN+lpTI/oN3xoIdD6Y6vfNItfmLxYuGU2t6T1/YOi5oQRNoqI4lFAxb4F8KD+SytmcfAyycWgwouZ09DGzCZbR9+HM3ODzahxdfoExkQV8R8K1sDIIOjYsycB3J4Zj/3Zcclh/FPH/Zte7+ta6yCoaThtMLnchpbLfJaV6sBephCUsHgqwKUE6ysyj4uucBFn4PAF91ABvLosnRXuFW82ogd4kvenq+Z8qPnxiKBQOqp0WEHzUwF25cN9C8o1YV6YjciQ/NA+algbvCcwOIT98chfpTP2GZLZsTpzSoJuRvRBjaDasItMcmnt8+cS5lcVFtGr95 X-MS-Exchange-AntiSpam-MessageData: 1eP0ctISWIW2VvgD3iAB1K4ydnB9RhCIdhZ+2GRkLuWvKssQdSc2fZjhF5rfpSv620f6FpgaVMTryIfKRaoPnsN5XXQ8glPX2NEorx0S37S9pkp7ir40va4UHcIjPE8m/NJAhw4fO2J4QIg60MP1CA== X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4256 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT014.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)(346002)(39860400002)(136003)(376002)(199004)(189003)(316002)(356004)(6496006)(54906003)(6862004)(235185007)(70206006)(66616009)(5660300002)(70586007)(4326008)(450100002)(6486002)(2906002)(16526019)(186003)(478600001)(26005)(336012)(36756003)(86362001)(26826003)(81156014)(8676002)(81166006)(956004)(2616005)(8936002)(44832011); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2299; 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; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 521951a9-a4e5-42a1-333c-08d7c4780f37 X-Forefront-PRVS: 0337AFFE9A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tlIvvkqa768VgN8YI/5aS06bzQX7jBH6DqOUZP9zxZbvFxflI8NpE8ztx01uSWSzQOzy0OWe4EYi8UPfj9IGgjsNgk7nduf4QTHKYlmKCdaqUbd1Ja+vf5X7cG8b3xHh4zyDEKoMKBvvWBetGEg0Dq3jEAB1khWS9qShtiVmkEl13QJHSa819Vgc3zCQSJkfHDcH6RIuFs8C7DWCruty9enDrAiGG301cPB6HWTzow/Yng1k0hhSBQNiX2J1vcwr3+LTX6Davy5RYKYHRroA9NyalGD8YUfOCzA6qI7yZytjs+RkyIDdgLU3xS2EIaqLMUjn+2RQm2tjtQTSNxMcUNd6Px9DWL1Bpihonnl4tUtiPGS0QUOo7gzpge2ISTyYzhORCzOHoHUPMLi4cghGhTha67flIUJsELOUx8S0RM2++aXyIy8Xfbj2rToYVsW2 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2020 22:20:30.2024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8eaaae16-52c4-49f8-5020-08d7c47813b7 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: HE1PR0802MB2299 X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, 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, 09 Mar 2020 22:20:34 -0000 --=-=-= Content-Type: text/plain Hi all, second version of the patch for the 200 characters limit for literal strings addressing comments. make check-jit is passing clean. Best Regards Andrea gcc/jit/ChangeLog 2020-??-?? 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-??-?? 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..1b3d5618779 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -220,6 +220,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-sum-of-squares.c */ #define create_code create_code_sum_of_squares #define verify_code verify_code_sum_of_squares 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); +} --=-=-=--