From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20049.outbound.protection.outlook.com [40.107.2.49]) by sourceware.org (Postfix) with ESMTPS id 68273388B02B; Wed, 3 Jun 2020 16:36:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 68273388B02B 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=D7aQ/HJDnMcFo+iVRv7qTpoJl9c4hSow86qZl/6HHR8=; b=GdVVcFuy9yBaF9EJxYNbV+h+xO99UFg6LlwOuNfo4CCnl3igl1pFca/win6273kKQ+sN7YSEKt4belWp5FJv+NxJPNPFeUvIO2EH5hwq4wWRWidZ4FsTJd/zGEy0DFAt6aFXXXaM+m+SucoKb/jOxL/CUFaghTGhUe8tSKU+51M= Received: from AM6P195CA0029.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::42) by AM6PR08MB3702.eurprd08.prod.outlook.com (2603:10a6:20b:8e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.21; Wed, 3 Jun 2020 16:36:37 +0000 Received: from VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:81:cafe::61) by AM6P195CA0029.outlook.office365.com (2603:10a6:209:81::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Wed, 3 Jun 2020 16:36:37 +0000 X-MS-Exchange-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 VE1EUR03FT015.mail.protection.outlook.com (10.152.18.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Wed, 3 Jun 2020 16:36:37 +0000 Received: ("Tessian outbound facc38080784:v57"); Wed, 03 Jun 2020 16:36:37 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ecfb3ba8c9da1eb0 X-CR-MTA-TID: 64aa7808 Received: from 4d259047fad8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0BC15C54-7292-4B4B-8A40-FA2D4419E249.1; Wed, 03 Jun 2020 16:36:31 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4d259047fad8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 03 Jun 2020 16:36:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/VM3/kuVl/9L4K6pkQgaQr/MzDBZkx8zsTgDm7YqreDS6fspRL9In06oUHnUeTAa04/i298H57SDg8TrRcrI0y3wINhSfUu0Erzkp/MRZlrpdBwZdJj1tohya9cBpnGSxRCsD5OrGwhBnublh1u4bdWMDlSLF0nQskNSC6OSAiUuMRNl3xqMUSvB2jCGimEYta142Ak8g+/a3isSNi3nFjtg4VvSOM5FGi6p7VRaDiSg4b2SwvZajpNQhisMZB1krbxvyqClK5/tFJw8wJ1gQUz/EMIskrWZlLaYbb9IZ0Y6n+dCUPsXaeNeo3jSeIZxnPst6NnjQ6n5Huok4n8OA== 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=D7aQ/HJDnMcFo+iVRv7qTpoJl9c4hSow86qZl/6HHR8=; b=bpAu3/W/5IKiXIs38i9OwH2NR4wO4mvKEd1WoDJ3/OfPDBTm60Gqs1GmOpb/TrLYHdVkVdAmcCEzxhf0UiAEO2YQv+d/DtBQjyzMXDUNe7nB29s9Zrkwqa/Q/ZT8ddNKVxA06JYfJuQPC9bVrKc1zTxco+TbNMcU5ZNlKgAA3SueREpXubCuaZ2Kw4auIH9kqc9LYht1wB56iX/qTK6keT/b9FrK6yDpFxxnlXLmuPoGXhEgbdma/5e+VeEEuNQVuZQIXZkL15tRw37GeBUqugpamNn7DxkSBWjvI8O9Z0OjqOqhVOjxjmtoQB3ey1GIJHryF81IbB4KHcoXlrLBgA== 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=D7aQ/HJDnMcFo+iVRv7qTpoJl9c4hSow86qZl/6HHR8=; b=GdVVcFuy9yBaF9EJxYNbV+h+xO99UFg6LlwOuNfo4CCnl3igl1pFca/win6273kKQ+sN7YSEKt4belWp5FJv+NxJPNPFeUvIO2EH5hwq4wWRWidZ4FsTJd/zGEy0DFAt6aFXXXaM+m+SucoKb/jOxL/CUFaghTGhUe8tSKU+51M= Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from DB7PR08MB3594.eurprd08.prod.outlook.com (2603:10a6:10:4e::11) by DB7PR08MB3739.eurprd08.prod.outlook.com (2603:10a6:10:79::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Wed, 3 Jun 2020 16:36:30 +0000 Received: from DB7PR08MB3594.eurprd08.prod.outlook.com ([fe80::5447:f1c0:97c:aa35]) by DB7PR08MB3594.eurprd08.prod.outlook.com ([fe80::5447:f1c0:97c:aa35%7]) with mapi id 15.20.3045.024; Wed, 3 Jun 2020 16:36:30 +0000 From: Andrea Corallo To: David Malcolm Cc: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org, nd@arm.com Subject: Re: [PATCH] libgccjit: Add new gcc_jit_context_new_blob entry point References: <59a8d345c642d49281a601278946e087a4bbe3e2.camel@redhat.com> Date: Wed, 03 Jun 2020 17:36:29 +0100 In-Reply-To: <59a8d345c642d49281a601278946e087a4bbe3e2.camel@redhat.com> (David Malcolm's message of "Wed, 03 Jun 2020 11:03:09 -0400") Message-ID: <87zh9kumwi.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: text/plain X-ClientProxiedBy: LNXP265CA0083.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::23) To DB7PR08MB3594.eurprd08.prod.outlook.com (2603:10a6:10:4e::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from krcb (217.140.106.49) by LNXP265CA0083.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22 via Frontend Transport; Wed, 3 Jun 2020 16:36:30 +0000 X-Originating-IP: [217.140.106.49] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 82093e12-ffa7-40d1-4f40-08d807dc4932 X-MS-TrafficTypeDiagnostic: DB7PR08MB3739:|AM6PR08MB3702: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 04238CD941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1RgGDpX4gKIRSLGApDkrxK2DVZHOlpc7MJwjJCEiaxOK6LldK2hK/BfT+FU9pCy71z+YEOF1+bzSn/T7l/P33adFxYnJqkK4tyK+6skoLQ2fucrAl9PlmQIp1uk56lgGbEtarT5EK2hozrLBja4tpTeU6a7rccM9bT+WjWK0L/CssK1yJ2UeZ3UJt0KA7cRWVv1eJCx1MIyanWK4XRvi1Pvae+aAHD2H705LIx9pHROjK8xD5BTCEziXiQrioOTy3rya769onqOp39+XlXlQiTpjnQYECNs9eJgVgWjH6WUeXUzfQjh8SFCZwOMfmQWVszce8TOo1vB5QhyBGdlI2g== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR08MB3594.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(346002)(366004)(396003)(376002)(2906002)(66556008)(8936002)(478600001)(66946007)(86362001)(316002)(6496006)(66476007)(83380400001)(8676002)(52116002)(956004)(44832011)(2616005)(6486002)(5660300002)(36756003)(4326008)(26005)(186003)(16526019)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GSbPQuUjmcWbr3a7fFMlg/H0rUqa7crAHaUZMyPV/V81FT0u3dK3Xx6RLNEbZ6ngwzycxAP+epArDbfwNHyJq0F6lnEBe2iiWI6FJY8V5hze0RT58Y9qYWMl7hCdgNCDOxyImjRcVjvdkCxUXepIL6t9qYYkJ8kUY4tKXemPwBsdNQzs3EDS9Uq+KEc6aLiFFCFs26W/H/5kROditPGH9bhM+6fyS0WnwvE1HFMDNcGsbWY4aQnOMOvTznsKbe+ZGgYct7KJswUlb1ikdl65hegsPuv1QF9f+K8YpL8jnaSebJ8yC5Ok+jF7oDcd4JYN02l3R9mwirHFyn9KILa6XCz5ltXmfmargH5hYSFhZce9aXex8dtIHetVofM9CSDZuqaCz7gF25Gnki0bBFuA5N5T06HPblOnmvr1FnqXkecK1TGSvntAI/l0RKt/Wg863FmWEtEJB0NWE5UT6h7kXHhYxsUlS1w1vqWMjGaeUyM= X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3739 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(376002)(136003)(396003)(346002)(46966005)(6862004)(16526019)(8936002)(478600001)(82740400003)(4326008)(186003)(70206006)(86362001)(70586007)(47076004)(450100002)(36756003)(36906005)(81166007)(82310400002)(8676002)(44832011)(26005)(6496006)(5660300002)(336012)(956004)(316002)(2616005)(6486002)(2906002)(356005)(83380400001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 9e2bff78-aa0b-4be3-db6e-08d807dc44d2 X-Forefront-PRVS: 04238CD941 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zb0dVx/YEpTJIL8yvvHeq41/pJGXqnrnemPFG+45wQxORnS6hs01ptaZZsocxkSzhFslYLQ2JG2puQsK1Vq8pRNKUgrxzxEm9C+OmQBLNFaZELN+Tlu+IizNSOqLrBhkoSD12JkNdg7XtHSBrqZY9sbTVn39Zyitlq71quJRfzozi9m5m19tpSmto6ybB7gvIsi0fQdpU8HUSvx0h1CqAJXgqXOsEvrOeAD69AZK9jcGcs29X8ATHbbeKID7BjNlKHh7aFFRAQdsRBZyL9WslW8CfA3PKuuS3/fIXgA7gSXUPuRJ5SGNGg1xObda3WhQzssz6u+c+NIMfwaWLy956+QBrSo8EZIoo7MfuvJbgeEXGMLXgSy3BRNgepLT8UckZKZXaI0g4OXujYTux0956g== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2020 16:36:37.3769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82093e12-ffa7-40d1-4f40-08d807dc4932 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: AM6PR08MB3702 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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: Wed, 03 Jun 2020 16:36:41 -0000 David Malcolm writes: > Thanks for the patch. > > Is this entrypoint only needed for the ahead-of-time use case? If the > client code is instead going to do an in-memory compilation, then I > believe it can simply build the buffer of data in memory and expose it > to the jitted code via gcc_jit_context_new_rvalue_from_ptr. Hi Dave, correct, if you can leak pointers into the generated code this entry point is likely to be unnecessary. > It occurred to me that the entrypoint is combining two things: > - creating a global char[] > - creating an initializer for that global > > which got me wondering if we should instead have a way to add > initializers for globals. > > My first thought was something like: > > gcc_jit_context_new_global_with_initializer > > which would be like gcc_jit_context_new_global but would have an > additional gcc_jit_rvalue *init_value param? > The global would have to be of kind GCC_JIT_GLOBAL_EXPORTED or > GCC_JIT_GLOBAL_INTERNAL, not GCC_JIT_GLOBAL_IMPORTED. > > Alternatively, maybe it would be better to have > > gcc_jit_global_set_initializer (gcc_jit_lvalue *global, > gcc_jit_rvalue *init_val); > > to make the API more flexible. > > But even if we had this, we'd still need some way to create the rvalue > for that initial value. Also, maybe there ought to be a distinction > between rvalues that can vary at runtime vs those that can be computed > at compile-time (and are thus suitable for use in static > initialization). > > I suspect you may have gone through the same thought process and come > up with a simpler approach. (I'm mostly just "thinking out loud" > here, sorry if it isn't very coherent). Yes I had kind of similar thoughs. Ideally would be good to have a generic solution, the complication is that as you mentioned not every rvalue is suitable for initializing every global, but rather the opposite. My fear was that the space to be covered would be non trivial for a robust solution in this case. Also I believe we currently have no way to express in libgccjit rvalues an array with some content, so how to use this as initializer? Perhaps also we should have a new type gcc_jit_initializer? On the other hand I thought that for simple things like integers the problem is tipically already solved with an assignment in some init code (infact I think so far nobody complained) while the real standing limitation is for blobs (perhaps I'm wrong). And in the end if you can stuff some data in, you can use it later for any scope. Another "hybrid" solution would be to have specific entry point for each type of the subset we want to allow for static initialization. This way we still control the creation of the initializer internally so it's safe. In this view this blob entry point would be just one of these (probably with a different name like 'gcc_jit_context_new_glob_init_char_array'). > Should it be a "const char[]" rather than just a "char[]"? Good question, I believe depends on the usecase so I left out the const. Perhaps should be a parameter of the entry point. > One specific nit about the patch: in compatibility.rst, there should be > a: > > .. _LIBGCCJIT_ABI_14: > > label before the heading. Ops > Hope this is constructive > Dave Sure it is. Thanks Andrea