From patchwork Thu Feb 15 20:42:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 201745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp109667dyb; Thu, 15 Feb 2024 12:43:14 -0800 (PST) X-Forwarded-Encrypted: i=4; AJvYcCVPm5l0JcEDY9q8VskHOdz0izw6xIaDkEMGFQn4OQnhC4IVaOT4E8nd70OyBewfVLsX4jlexGVN9Pu7009JW/GjEEkRGg== X-Google-Smtp-Source: AGHT+IFiuhtfUsQIB8Q0XFZMUBEWjYLB0EiGdNH8YzgSNgLYfVbeiS2xlSK8psP7WCUBtHi9/Bq/ X-Received: by 2002:a05:6808:1884:b0:3c1:31e7:9059 with SMTP id bi4-20020a056808188400b003c131e79059mr4124191oib.47.1708029794231; Thu, 15 Feb 2024 12:43:14 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1708029794; cv=pass; d=google.com; s=arc-20160816; b=HpQSneOlleoHBFL2yCRVDp6t+63t0jsRDZyPgRiNwtE9MyvQeuhHjJe8I44tSWzlz5 ddJMtDaYvUoTPKoRsj9RP4eEYCOLCRBsxxSLm0YODlWrFJN1UoZJoZDJNgSvf4UZfvvG YmeWGPfAPokpz7GA8pkRSQj55LHiyuXh19AQYI40Kg0zP6J/Lusx4pBKVwGWrcDbOQkL ylHRMoNTf3SbFDQndKMeQ7eJxaUzhiAf66XJQceTILuZvGsVw7k0jRF+a2qjtzbKHt2i 6AqXaHU45ea/K1WA86Ff7pGlszPk7q4xW4niqwkkzNl1BQn5ck01lfsY4Yz4+IgIsrO3 /6dw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=i5yQKUy13K1ZifbT7N+I0Eu9fNPHgDsgbBQk0wRMzDA=; fh=WTJsRs4G52V/gMcjhbfNbo8t5XJoGVmdKBTHDFPm0CA=; b=vicgSvRuh5kNckdnOilQb7HDgrQ5zufqVkWikZsJu1tdnS3XbrV3xROrjSKBBQyw0c fpbuQ0AuC57KciKwzsjlRcb1DBcnukbhxZ4uUAvqnUPU96z7rG+C/r8EqH9ExmMAZAhC YS8FsIWtMv0m6imT4i7kPfi0pojeS9cdQn8W/2N+CQNUxkbIqZlynYsKYd25fryjTaPk f/7H9LDN20GI2kSOGc159JclWEe65+ougxqPrZ7mpGy89Xp8qevdhuRo2krXmooBLDBj aFAxOhXmNRBLd2JZ5xgsTzi2fe3vHZXAm4KIZrx1nSyCo9pmM+xnmS5Mo5i2D98t+AcP eHSw==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=NSUMIL4j; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=DVUdsZvA; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ew15-20020a0562140aaf00b0068f1df5794dsi1428655qvb.264.2024.02.15.12.43.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 12:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=NSUMIL4j; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=DVUdsZvA; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1D6D386D62D for ; Thu, 15 Feb 2024 20:43:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 678A7386C5B0 for ; Thu, 15 Feb 2024 20:42:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 678A7386C5B0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 678A7386C5B0 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708029754; cv=pass; b=IvEGfF+zYkuJ7e9BGRghwCV1hRnNUofXt45VoQ2dYhCtBqbk8PK7QerYl+Dc+7D+dG6gWJEU1dyfjkV2WO+tKee0soqyq1XdvynjBgiM895wdAr1K/bPj+VVfRmw1F2wouiugrWtfF3OVe1m26prF9n+WYBqeizqjDh5LOzBatI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708029754; c=relaxed/simple; bh=cFz8j1sLZIBsYl6afIX00qoY8He42bjVbSTTMpAWXNA=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=CGjXFjqMIw5cNT1IHECW9aYiFgs6sAK7oPn4sbiJI7EcWfTrlSvB4bd0TBBYub1fNCMKf+Ayd0EHsET9hRNQszBpfa2R76nsBcGt7YLn0+ObtcbG9UVm80BNelCdVNglPjegAGdtehcHH5WehvsLSScjte0gYFx9ZpYIhD3QT5s= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41FFTBLT006118 for ; Thu, 15 Feb 2024 20:42:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=i5yQKUy13K1ZifbT7N+I0Eu9fNPHgDsgbBQk0wRMzDA=; b=NSUMIL4jrfy7xsCmaHVmcgr6nhvujaB5BAQ0vKZcMk9JN1sbqb2fWjVaLzK0dbCR2RWl AJbUX2nP2WedUC7w3T0sWi4IbAtg/iAdxL9Po+b1+GRnUBgbkS13o0Uhgrl4oi2co4yR Ewgst8haJAlq8fmD2gutAHiQCehv6Y6K3qASZ2MIXnfbh5Q5FjYgQu/SEMySnG7GNxzx PDcONNp49tBCUX6wOaPQO5lqWueyVjdwRfj4CLK8qJBLdFriQrHLGhkkvaJlYpF/YHCD 4PIbv3435gB8zoM83eP0zbST4R+zs0rMMcKtY/9ICQJoLI/Wp0WXO+MbTBgu9m9WVMLG 2Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w92ppk8qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 15 Feb 2024 20:42:21 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 41FJu4NR015066 for ; Thu, 15 Feb 2024 20:42:17 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w5ykatvk6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 15 Feb 2024 20:42:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DFaValicqwrL3142akbYxldKhzfOrPzXJQK59fDn7gcmcmhc6hFMq6YjLyIIgTvyKCU5514EgmOJhQHUx5SpFhYK9mNybyTeAuBh3JHjGeF6BCRiC98092NsHiwaUVwXFi0kZQpx8Rkpt23rr4y4rN4pOTVz7Rx+NaSUiZ3dpRodLiYDbuvSqMjC1lqLeCAbw3mxpVtYDBVIHQquQkahxjRTQ3dDNZRXl69FTarU8NAofCFHqVAPk1Xcvo1Cr/brGgJUPvUaZNQlFuqaUJaIGQlxZDoOsbtEzsiNq2zVAUsrOzPwMWXIasD4gTkleRopF/dxcLJ1DItSiv0W2CViPA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i5yQKUy13K1ZifbT7N+I0Eu9fNPHgDsgbBQk0wRMzDA=; b=bLe6y88C28WNWKGgaE5bxx8TRNcMxLswRu/l9ff0BOvAFhF5O8jEY9sR1hUfOFuAeEr0eCpeeUS7bxc5gKFd7KAmNvtaWbgGiC65n6zGkyXMlsPnqWKLOy6xIdJ8yjtkXauKUOmHJDpgx6vTknkmtFud4b96OLYpAPFkUofK9D6VxltbNHu13bqFtnAWuZiCDnhbnxs244R6vTWKvB4ZA7ef5LOy5Zic1FhSwBq8EWvckvQeaEdnicuAgu+dwMitDA0ApZAgBabset9P9/P00OX4+NT1Hcn+izY4jwP/bhLS5tUxdbBbzcnz/K4xuK+EiiZIqWRS55ZZhXVTCrh8hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i5yQKUy13K1ZifbT7N+I0Eu9fNPHgDsgbBQk0wRMzDA=; b=DVUdsZvACXpBLTQhZLOzGFsMKNUAYMnzmWS6TDwxagi7cNaEEXvj409Rj3wxKQ6OJwDv57wmDRz8pRhFe6JUyihzkMNE2NrWpga2x9EZTx+sAHegz4sq3sUrTn2E68G4RbSVoJs2AXr3P7Zi1MI9fd/NaybRqX83BqI8pmMBCew= Received: from DS0PR10MB7953.namprd10.prod.outlook.com (2603:10b6:8:1a1::22) by IA1PR10MB6028.namprd10.prod.outlook.com (2603:10b6:208:388::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.29; Thu, 15 Feb 2024 20:42:14 +0000 Received: from DS0PR10MB7953.namprd10.prod.outlook.com ([fe80::9722:fdc5:e685:633]) by DS0PR10MB7953.namprd10.prod.outlook.com ([fe80::9722:fdc5:e685:633%7]) with mapi id 15.20.7270.036; Thu, 15 Feb 2024 20:42:14 +0000 From: David Faust To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com Subject: [PATCH] bpf: add inline memmove and memcpy expansion Date: Thu, 15 Feb 2024 12:42:08 -0800 Message-ID: <20240215204208.9465-1-david.faust@oracle.com> X-Mailer: git-send-email 2.41.0 X-ClientProxiedBy: SJ0P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::28) To DS0PR10MB7953.namprd10.prod.outlook.com (2603:10b6:8:1a1::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7953:EE_|IA1PR10MB6028:EE_ X-MS-Office365-Filtering-Correlation-Id: 47cb4d74-3476-4440-0882-08dc2e6697be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ViClQoxpCmrlpy2dr8fFYypja1ZlLCau8+49HGALSTzznRhc06ZJFCLfvYt9bWVyAIVn4di4YMEqLge6rgjxJCYfh8jRgENyhi0h3eql3g6x2jGp425zETb/x+BvXqAfUZkn0AWbeKtRHMxkr3nDQCGJr+uGVs7OtdE+ZVp7Q6V8rhSDBop8v9UeXSrcnIRzZTYElm2kYud56bnOO9t3M4GBJfF4pw9/YkgF1np8HTuqbFgW+vSxK1JatUHxxUofbi2gxZCN8WWS5KgnO/AXCVCPgr+HzxmWzC57K/SkDHndWDIy3QsOk1WU4cFgKlBP56gMyeCKxMq9e9ywpkhCJa75uwvsCWIUM1GMZHHYZuqRmmSDTFRSoaazJCkv9+CmBgEGe1ckX/1CvIQHtz9h/T+Lg52fA+mUhphNQaZZFCSG0GLeRufyzdqYp4L9FQlSkuPWVUMRyYuWql54yx7YLQ3Dm9NpIuMbtpG6j9RM+ibYYhMxYhyTctChAjUNA4jwiEn4Ms6aQUKdI0tw6PhYk4a4lNfkf7CfG8a1R7f7z1Y= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR10MB7953.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(39860400002)(376002)(366004)(136003)(346002)(230922051799003)(230273577357003)(1800799012)(451199024)(64100799003)(186009)(478600001)(6512007)(6486002)(6506007)(66476007)(8936002)(66946007)(8676002)(66556008)(41300700001)(6916009)(6666004)(316002)(4326008)(38100700002)(86362001)(83380400001)(1076003)(107886003)(2616005)(26005)(36756003)(5660300002)(2906002)(84970400001)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bcYPuZ7S1rhotwd21XGAdxcgmBTN1Gbb7MeHyi5hp+xkf3OGG7xkzPENU9XhS/cnt8k3jE1Z6wOcF8MBx7TLxQeMK8Z9LdWtdaCLYtluwjMrREu/XzrOyWk+fgRRE92TKOBm9QpoQ+LPt68bEY3gHCElUXDcVnwitwoC0jpt1vksHKskyTyjUJCpoigVlqW0zMGgyufeUJWELGWq1ohOH9HNxIoRtTr3YcGPBXlUl1uE+mG5DpLWI2P7Bdx53m3qUNTaNn2yh8RaktJmTL6bYY/Hbk9diOn1SGEK+nk8/X2LVe85/H4hrPvcd5SS0BRxi09fdLXNdhCDdZ927ibezReUP+MCOE2jHas21yxz/Kad+Jhpox/sNqPjH2xwRUaSp14Ou4QovcRyKrOmLxAfm0lUw0LRNAvRt1VwfCSsIjR/7mNJzN/OH/NlYCYSW9i0Li/bPmkPBRmaZjfcQ8c5FfILdOh5CSSVdX721w7LoJWdhZeFcC+BGmAPlcXj+OYvtxfxidShH5ZG/LrS9YztEtwpPnmQf1qCy3sNpkKGrJfch0OGw9Sxbb1LvWXKV2p6IqD80YG1Jt3sLzrJqrbxI6IDpjAED+J8Yvkg8OhYPmdLtQBhNWLP+lt+f6lbwI4JTBefhaUF+XS25gBvWg31OlyurXs+wvitaTWRk3ruJ2HNmBrZqBaZR95kLHL3adIaMbke2RNZBy5UrV1yGZUQPJcHVi/pROMf4yuwmGPAG9gOzsCX5B1RDI5ANF4tIs6deuz4BrvezaT2pnAj8etooo0N8Mx4uk2Qi22RQCrKrvHB4ooE/LIqx/bkiylfUEeYPpvIboFYRl8ycMvy1cMS+OxSPp4o8H/buZ7sWSVJrzYdke44Q0/CE+HZk9CRkiyDas5lTeuyD/mMclD2fzBf07BSvY2ULvVdFpVa3rVFhWmUA0R9HAaWylxWJHKMV/Qfb3JjzjRCZGwDtNlkgRmQ1yWAXH7DDytsu64hC4G54Ayxei47Rgpbf8INo++RjyQhhPDJu6PWM8xZqT5GE7lCV+dYmvHxDxgbxTJEDCwz9qGu1mEVTAxmY3xpcsLPikat0I/rLAAmfzAQoMiQZ5aA3d4Ls9SQ9yVuNF6vsUEkaMWIM2IFAgIVv44z3fw8NWvi5K099//JosmrSFZpS3po7ZVweYdQ8zaI9s/R4A2w6k7GTHsHUCCLmkziM1qGbl1NOUwPBIoBvedQh/UyY9NURZPg/C4ZJUtaE1un6RN2uI//KhUh5sN0lRAe8ArK9umIqNA6JCZmKhkqXWLcnWhvKbCAnCEm2/BJLrZBBHh/ebyZrrBbGZdsFrVQkofBTwnlJ5UJ1xzzytZNMpnmZ3ucfK7eUkwX1ULXqDm/hUpuE/wokaCQN8gZGEVzSmhBMsl5bCdkeWvA0n3eGO3APPcaykZRLzZiqjbCNAUxEBcsLADK932pxgCbo1Zdu3AHabQZYEqy8v+0Mg0xnhdP4Tm8T0+aofOXcbwrKCgFdvC835T453rgAAnKKP5fcGgYq/0vGZYv5wyv6IzneGCkg2R4J9Y/9AvB1wHY0gNTlOi7/2eCayBsBbrBkyzgqe/b4VAL X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Y8anpO1tj8lazhkDDITJXaX23aO+bE0Mt/ycVraaeIfbZ9+BMzz1ruvkpyAsxsb9l1Pt2C8AudpeQNyr6FEBqG1Ies6vdgKJZBT8behzTMTgcaZ2X2qknWpYFqp44tSVgVovzflEgKWPYKpFQ6cc96fxqInHpruEg6E1oJsoWjBis03acQXU1g4D0kh93EYkiRo7Yc1Q0ZRSqKGYVwvx9csQhZ9Lbyd79QDC6Fg5rZhCPhltZsyGugvI6Ag+k2RKnCMRL3pP05P3vmj748J5k+BDwJe3pqkcNxRBJRxqZ509eRrKA6N4RMXHnsQlw9yTjEFII0GaOac+lQlCuj3ScW27JK6Pgljr/0zn+2IOxxx0H70VD7NCnKxXQtcfMENl1ydYsZkiKntiAKsDSm+1+ZG3vECg980wlSwrjkQaRLeC1wCC19xHIHnU7boY5Bf7AJ2kvPc5fBhn8QvI0DpVenRwa9Kgi3vQP6lfr96USi2d2KxZPXPF0ZQDNfcZuySabYbhbm13y4kKKwOFrdARPYogBjAfPshgdVkwUE8JNs6Om1FdXFZRgRBdSMmTPdg5GWhdh+ZwhvakFTfMKR/8N9UMfsATxwdoFHa29S2l/5o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47cb4d74-3476-4440-0882-08dc2e6697be X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7953.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2024 20:42:14.8533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +amWXpdbKBs5fjJyp+YHFUpBlNbz3DejtooLbVpO/Wlk+YgQ+o9J/DaLw4s1BacFMcOpowjX8QENsxOEP1Y3zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6028 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-15_19,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150166 X-Proofpoint-ORIG-GUID: VjK1yov2ZplNHP0CoIkNue0uN5eRnKiT X-Proofpoint-GUID: VjK1yov2ZplNHP0CoIkNue0uN5eRnKiT X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790999049249937031 X-GMAIL-MSGID: 1790999049249937031 BPF programs are not typically linked, which means we cannot fall back on library calls to implement __builtin_{memmove,memcpy} and should always expand them inline if possible. GCC already successfully expands these builtins inline in many cases, but failed to do so for a few for simple cases involving overlapping memmove in the kernel BPF selftests and was instead emitting a libcall. This patch implments a simple inline expansion of memcpy and memmove in the BPF backend in a verifier-friendly way, with the caveat that the size must be an integer constant, which is also required by clang. Tested for bpf-unknown-none on x86_64-linux-gnu host. Also tested against the BPF verifier by compiling and loading a test program with overlapping memmove (essentially the memmove-1.c test) which failed before due to a libcall, and now successfully loads and passes the verifier. gcc/ * config/bpf/bpf-protos.h (bpf_expand_cpymem): New. * config/bpf/bpf.cc: (emit_move_loop, CPYMEM_EXPAND_ERR) (bpf_expand_cpymem): New. * config/bpf/bpf.md: (cpymemdi, movmemdi): New define_expands. gcc/testsuite/ * gcc.target/bpf/memcpy-1.c: New test. * gcc.target/bpf/memmove-1.c: New test. * gcc.target/bpf/memmove-2.c: New test. --- gcc/config/bpf/bpf-protos.h | 2 + gcc/config/bpf/bpf.cc | 129 +++++++++++++++++++++++ gcc/config/bpf/bpf.md | 36 +++++++ gcc/testsuite/gcc.target/bpf/memcpy-1.c | 26 +++++ gcc/testsuite/gcc.target/bpf/memmove-1.c | 46 ++++++++ gcc/testsuite/gcc.target/bpf/memmove-2.c | 23 ++++ 6 files changed, 262 insertions(+) create mode 100644 gcc/testsuite/gcc.target/bpf/memcpy-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/memmove-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/memmove-2.c diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h index 46d950bd990..366acb87ae4 100644 --- a/gcc/config/bpf/bpf-protos.h +++ b/gcc/config/bpf/bpf-protos.h @@ -35,4 +35,6 @@ const char *bpf_add_core_reloc (rtx *operands, const char *templ); class gimple_opt_pass; gimple_opt_pass *make_pass_lower_bpf_core (gcc::context *ctxt); +bool bpf_expand_cpymem (rtx *, bool); + #endif /* ! GCC_BPF_PROTOS_H */ diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc index d6ca47eeecb..c90d29d12ff 100644 --- a/gcc/config/bpf/bpf.cc +++ b/gcc/config/bpf/bpf.cc @@ -1184,6 +1184,135 @@ bpf_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size, #define TARGET_USE_BY_PIECES_INFRASTRUCTURE_P \ bpf_use_by_pieces_infrastructure_p +/* Helper for bpf_expand_cpymem. Emit an unrolled loop moving the bytes + from SRC to DST. */ + +static void +emit_move_loop (rtx src, rtx dst, machine_mode mode, int offset, int inc, + unsigned iters, unsigned remainder) +{ + rtx reg = gen_reg_rtx (mode); + + /* First copy in chunks as large as alignment permits. */ + for (unsigned int i = 0; i < iters; i++) + { + emit_move_insn (reg, adjust_address (src, mode, offset)); + emit_move_insn (adjust_address (dst, mode, offset), reg); + offset += inc; + } + + /* Handle remaining bytes which might be smaller than the chunks + used above. */ + if (remainder & 4) + { + emit_move_insn (reg, adjust_address (src, SImode, offset)); + emit_move_insn (adjust_address (dst, SImode, offset), reg); + offset += (inc < 0 ? -4 : 4); + remainder -= 4; + } + if (remainder & 2) + { + emit_move_insn (reg, adjust_address (src, HImode, offset)); + emit_move_insn (adjust_address (dst, HImode, offset), reg); + offset += (inc < 0 ? -2 : 2); + remainder -= 2; + } + if (remainder & 1) + { + emit_move_insn (reg, adjust_address (src, QImode, offset)); + emit_move_insn (adjust_address (dst, QImode, offset), reg); + } +} + +/* Error if we cannot completely expand the memcpy/memmove inline, + unless we are building libgcc. */ +#define CPYMEM_EXPAND_ERR(LOC, MSG) \ + do \ + { \ + if (flag_building_libgcc) \ + warning (LOC, MSG " for BPF memcpy/memmove expansion; " \ + "a libcall will be emitted"); \ + else \ + error (MSG " for BPF memcpy/memmove expansion"); \ + } while (0); + +/* Expand cpymem/movmem, as from __builtin_memcpy/memmove. + OPERANDS are the same as the cpymem/movmem patterns. + IS_MOVE is true if this is a memmove, false for memcpy. + Return true if we successfully expanded, or false if we cannot + and must punt to a libcall. */ + +bool +bpf_expand_cpymem (rtx *operands, bool is_move) +{ + /* Size and alignment must be constant. */ + if (!CONST_INT_P (operands[2])) + { + CPYMEM_EXPAND_ERR (RTL_LOCATION (operands[2]), + "unsupported variable size"); + return false; + } + if (!CONST_INT_P (operands[3])) + { + CPYMEM_EXPAND_ERR (RTL_LOCATION (operands[3]), + "unsupported variable alignment"); + return false; + } + + rtx dst = operands[0]; + rtx src = operands[1]; + rtx size = operands[2]; + unsigned HOST_WIDE_INT size_bytes = UINTVAL (size); + unsigned align = UINTVAL (operands[3]); + enum machine_mode mode; + switch (align) + { + case 1: mode = QImode; break; + case 2: mode = HImode; break; + case 4: mode = SImode; break; + case 8: mode = DImode; break; + default: + CPYMEM_EXPAND_ERR (RTL_LOCATION (operands[3]), + "unsupported alignment"); + return false; + } + + unsigned iters = size_bytes >> ceil_log2 (align); + unsigned remainder = size_bytes & (align - 1); + + int inc = GET_MODE_SIZE (mode); + rtx_code_label *fwd_label, *done_label; + if (is_move) + { + /* For memmove, be careful of overlap. It is not a concern for memcpy. + To handle overlap, we check (at runtime) if SRC < DST, and if so do + the move "backwards" starting from SRC + SIZE. */ + fwd_label = gen_label_rtx (); + done_label = gen_label_rtx (); + + rtx dst_addr = copy_to_mode_reg (Pmode, XEXP (dst, 0)); + rtx src_addr = copy_to_mode_reg (Pmode, XEXP (src, 0)); + emit_cmp_and_jump_insns (src_addr, dst_addr, GEU, NULL_RTX, Pmode, + true, fwd_label, profile_probability::even ()); + + /* Emit the "backwards" unrolled loop. */ + emit_move_loop (src, dst, mode, size_bytes, -inc, iters, remainder); + emit_jump_insn (gen_jump (done_label)); + emit_barrier (); + + emit_label (fwd_label); + } + + emit_move_loop (src, dst, mode, 0, inc, iters, remainder); + + if (is_move) + emit_label (done_label); + + return true; +} + +#undef CPYMEM_EXPAND_ERR + /* Finally, build the GCC target. */ struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md index 50df1aaa3e2..ca677bc6b50 100644 --- a/gcc/config/bpf/bpf.md +++ b/gcc/config/bpf/bpf.md @@ -627,4 +627,40 @@ (define_insn "ldabs" "{ldabs\t%0|r0 = *( *) skb[%0]}" [(set_attr "type" "ld")]) +;;; memmove and memcopy + +;; 0 is dst +;; 1 is src +;; 2 is size of copy in bytes +;; 3 is alignment + +(define_expand "cpymemdi" + [(match_operand:BLK 0 "memory_operand") + (match_operand:BLK 1 "memory_operand") + (match_operand:DI 2 "general_operand") + (match_operand:DI 3 "immediate_operand")] + "" +{ + if (bpf_expand_cpymem (operands, false)) + DONE; + FAIL; +}) + +;; 0 is dst +;; 1 is src +;; 2 is size of copy in bytes +;; 3 is alignment + +(define_expand "movmemdi" + [(match_operand:BLK 0 "memory_operand") + (match_operand:BLK 1 "memory_operand") + (match_operand:DI 2 "general_operand") + (match_operand:DI 3 "immediate_operand")] + "" +{ + if (bpf_expand_cpymem (operands, true)) + DONE; + FAIL; +}) + (include "atomic.md") diff --git a/gcc/testsuite/gcc.target/bpf/memcpy-1.c b/gcc/testsuite/gcc.target/bpf/memcpy-1.c new file mode 100644 index 00000000000..6c9707f24e8 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/memcpy-1.c @@ -0,0 +1,26 @@ +/* Ensure memcpy is expanded inline rather than emitting a libcall. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct context { + unsigned int data; + unsigned int data_end; + unsigned int data_meta; + unsigned int ingress; + unsigned int queue_index; + unsigned int egress; +}; + +void +cpy_1(struct context *ctx) +{ + void *data = (void *)(long)ctx->data; + char *dest; + dest = data; + dest += 16; + + __builtin_memcpy (dest, data, 8); +} + +/* { dg-final { scan-assembler-times "call" 0 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/memmove-1.c b/gcc/testsuite/gcc.target/bpf/memmove-1.c new file mode 100644 index 00000000000..3b8ba82639e --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/memmove-1.c @@ -0,0 +1,46 @@ +/* Ensure memmove is expanded inline rather than emitting a libcall. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct context { + unsigned int data; + unsigned int data_end; + unsigned int data_meta; + unsigned int ingress; + unsigned int queue_index; + unsigned int egress; +}; + +void +mov_1_nooverlap (struct context *ctx) +{ + void *data = (void *)(long)ctx->data; + char *dest; + dest = data; + dest += 16; + + __builtin_memmove (dest, data, 12); +} + +void +mov_1_overlap (struct context *ctx) +{ + void *data = (void *)(long)ctx->data; + char *dest; + dest = data; + dest += 4; + + __builtin_memmove (dest, data, 12); +} + +void +mov_1_arbitrary (struct context *ctx_a, struct context *ctx_b) +{ + void *src = (void *)(long)ctx_a->data; + void *dst = (void *)(long)ctx_b->data; + + __builtin_memmove (dst, src, 12); +} + +/* { dg-final { scan-assembler-times "call" 0 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/memmove-2.c b/gcc/testsuite/gcc.target/bpf/memmove-2.c new file mode 100644 index 00000000000..0ef34131080 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/memmove-2.c @@ -0,0 +1,23 @@ +/* Test that we error if memmove cannot be expanded inline. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned int __u32; + +struct context { + unsigned int data; + unsigned int data_end; + unsigned int data_meta; +}; + +void +mov_2_unsupported (struct context *ctx) +{ + void *data = (void *)(long)ctx->data; + char *dest; + dest = data; + dest += 4; + + __builtin_memmove (dest, data, ctx->data_meta); /* { dg-error "unsupported variable size" } */ +}