From patchwork Fri Sep 27 16:49:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 98076 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17F95385DDD4 for ; Fri, 27 Sep 2024 16:50:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id EA7593858CDB for ; Fri, 27 Sep 2024 16:49:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA7593858CDB Authentication-Results: sourceware.org; dmarc=pass (p=reject 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 EA7593858CDB Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1727455795; cv=pass; b=rBARfAbWQFEh6D28Z7OfIwyNb2ufXUPQ6NOC4hwO9iiViyZlPRE42XlYmqIyvPYKukh9O1SQY6Fkw2gMaTnw8KGSPsV9hqFZNAaRCjrC7JE1JevtTO0xH5fChSf7sPRtL26+ri3syLI0CjAAEreRLQndnqr3fITtxvrwtE60cNs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1727455795; c=relaxed/simple; bh=btFCBsS8aImiWElucprK/0Hfdz7mHrTy/UCDD+ViWOY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=sAhaS/ATGqZ+DAoBlDTFnUficenO8FidUJgwvqLS02awogFmkEAX/ocFmqs7ZyDfTDA8zGgPqbWcgQoeOLhoqfBICKf88P2sRHUlUgv+YyqQD9Gap2ZGtVoXNkuKt0bNYo4+0JkePNNlQLetNi5ylCVDauTumfuS2EjFpY8KUYU= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48RGBZ3N021297 for ; Fri, 27 Sep 2024 16:49:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=PGx5Bx4G4f4eplRImWb3w05t4kDz01wP6CFwjjUdLqw=; b= gMcveO7DyjcCDV9yNFx5M10mT3/V6e+njUmOn8Jmp8g4PYD9uRCALWVHqoTvonyc pi/ilUMErvVOt8GkJhXmlKQfDeDsr/CmOTrf1QLoyvfMqXTP+9E6cCKDcyCO6KbR p8ide2+/6lRW8EHyy6tWNAvvaDGpEQ4BRgXsfelvTTEz3HmANPzjnQE584aJHXVb 5rmTCFAvQpG5GI99eV104Rs72y4+ze5rLZj4kyiAbA68wxMc4unVoyf8IqQvB57s 05hMYn9fEYNhAo7WHG8aRjeG2s79Q6C4455/NwdHzyTMduxPjxjv9xTeTkwE7Cg4 U6NsfMT53u1KBGgtWGYmsA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41sp6cnsur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 27 Sep 2024 16:49:53 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48RFVH6v009949 for ; Fri, 27 Sep 2024 16:49:52 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41smkdgkkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 27 Sep 2024 16:49:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SgQSayHEnmN+SPeUsIBJ7dMXalJTZy3HPHbfzwtLYENRm/vCGCNvFK/zYJTs3LmuocY29WCmGsis/2rgFqbW+IuSqoL7anP62f9FvaSt6YibWhPjjoID3CPrI6uQgjeFKTdGlhOekjzEnOgWzWCSpYZVyc60ZuSyxHzoIMtfrOB1Zc6FdKn66Mssj9WbTp3qQk7P0aTQ7PpHo89boMPfAP1o3tyQCTBPzpqOupIEck3AKKqy0XhRjOvMoQG5aeuGk5Lt/tXnJC/5CrwohAdei4IvT7K/1/thxJXUn0bJiL0RMB034FLdOVsO/5Oyy4rQ8fzwgzPsnlTOJJYd1c2xnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PGx5Bx4G4f4eplRImWb3w05t4kDz01wP6CFwjjUdLqw=; b=hemnc8Dp35JL07TaZLvb0dYO6AosqPjhMLjYGpyYMdisQ2b2PP31+G+o+Q+G+10cwpzWh3LQGoKcxq4ubxKcez5Tge/fJRLrLEUK7YIvw/PU2Tynd+bkHz1b0JMGTNXsroedBs3rnbxLtXZWKjc6IBqVCCFbdIWEs7k5WMylZ4U+cL1NlAIcOWj4CpKQq1V/Gufcf9qanaEocCN8JwPhC/DvHdgXmR1GuGlbut1nIpJAKj6MWRuz8AqKs8S0DZsdWE31qvBG1Xub+bM0tN4RS0mXFWfW6a9p/oZN7HYiFADvdE+7nMVhEc00DpYfdUwhAZklOIDGEdP9KUufF/GYXg== 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=PGx5Bx4G4f4eplRImWb3w05t4kDz01wP6CFwjjUdLqw=; b=JDwcUwJ7MP2tEuWITjeKc6n0QAnvFbtauXhHmws7ZDZ97t18OFAlUG+ClXWJYnI9P7M6pGOvpvjq1qh97bzMQh2+Lgy5jZ3YJJjH9lk9q4hhrevUMdsbNk5Z49b0C4HHBu8OAjYCwUbqQxphBI2OjQ+BOcxUyKIqyuViMSWQ7hY= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by SN4PR10MB5606.namprd10.prod.outlook.com (2603:10b6:806:209::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.8; Fri, 27 Sep 2024 16:49:49 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::5033:84a3:f348:fefb%2]) with mapi id 15.20.8026.005; Fri, 27 Sep 2024 16:49:49 +0000 From: Cupertino Miranda To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com, david.faust@oracle.com, elena.zannoni@oracle.com, Cupertino Miranda Subject: [PATCH 2/3] bpf: calls do not promote attr access_index on lhs Date: Fri, 27 Sep 2024 17:49:16 +0100 Message-Id: <20240927164917.141266-3-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240927164917.141266-1-cupertino.miranda@oracle.com> References: <20240927164917.141266-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO4P123CA0043.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::12) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|SN4PR10MB5606:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e8cb218-c3d6-466c-e73a-08dcdf1466a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|10070799003|366016; X-Microsoft-Antispam-Message-Info: fFEHnY9r70oCBHRiWVyRPVk6iEgQ16Uufk1+jugw9MnPIF1C6WIAcg8rwUhWx2PATz+vmlMrzj6ekq8dWlL/EeIjq2uuwhBcUdS2+ib3/l018cIU1Q/d8OF8EjOLhkAEa3INeqHmB/RN0JXcLEEWIVLkpzBq4a3tlNa4oAhK+8nYWiLLS2ZIov/cc4Bru/BqFGfwofBCW9McRN4dIB3aEWGSXHQ5hFPjemZNUmcS8suCAkguCuZjm4NygmJoRVe+AfP3ufyhpw/ngbuWiKx2qZKjoJ8/cw9p2PMnPv5roiv+f0/dfCk1k2VKTr+6tG9sQ2YpdiSKHyEwEYtCu2aT2pByn41VdU1clNRHFUf9+NV7urtNqAPovxEtitoSWSAPEk6AJKBqG41NtLxEgnufzmknzxVPKYCenZfd10K7S2HCEW6cK4k+7Ceac7v5jGsKboWiat4or4Fu3cxL9h5mXr23gffuGF+/Ua9reYVXti66PE9NAOb8czP2Hea8IFpXb1VGIIQhkkdHKj6bcqq4O9aBN36NxDQfYPUcwAWDoHK1r30oBHvIu4OodhYK7T0m4ZassepgqHfT8euUYvtwgzn6H9W9bUSlb7M8wgMCjJZyoov9auyMYuYaXs2vIlp74ZnbzS9uHS31C+VLjlNXhT6TN3kxNZWUUX9RG//3pVZCjJU7WAWJn6hiFO1fJVLwXrPqEA0gZZbRleF0ZM+zaaytQP6IHzYPIW3ALTgom/czSyGdJ3mIek7883LNe9c5q1JjHglwnP+5ukHmGuBy/BpnmqGvf1aUqKFCe6nclwtXbqyUhLHoY3RAyS1BTZWDCBs8r9MuH+y6rohjcEXoc3Tgj0rwPSxvboyXeSvwriCkqiExv5ywpYCMY83rFmqXgFNmvkaSkrsw14clSQdxEs9d8JeFDtAkP9hRE/OJzDhGnwo4OaFknglK/qp2+Pxw/CYdUNM5r/zOJwy5swFxj8Wy8GqSbAsvRVOh/B+oVaOzyyH2CTPUve8ko6/X0y6iIggIaiOdPVqDsA4NcvbMVnoLUnq0u2AkNkhB8yhNBp8/ObayTUgCyaTDDJFLhGnLPgomHwCsXTo/5hYFKmWjO3BpxXu6YZ5SGy2ePSccFZii8Nm3tvWhoDo1SKcflZveaz9kB3U6YCi8GPBAt+srFYjbCi1TEUnQN4Xwhz6+QWiyncQR8KAZxb/EPND0hZKrp+XjoK/4tWt6/BnfCqklw4uzrDVh9VlC62FujcZxBWTQ+30PwwxD46etr7AK5YczyjWAuInsaWQpD0Oz5/teluv9uPHckCiAanO/Vs2IqP+wl4W/XDclNvbCJYuJqEDVJKRDmCI7C6OnDu4ilO9uTg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB4382.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(10070799003)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rVRZALytdNq9LXidNrTlSoZFWtZaf2iy5q7k824uD4KBDuikQPofz50LtGL+9/lrnTjouN+SG0FGTxt1i7sTxWSFayVOYE/ZwsPdGH08boI6VnBXWstMokD752NJ8Okw4QjNEH9cNF9kTMdSdUrA3zw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xia29zZOTAMFH3w6BJX+Ya/PSbPHINovHKOngR3w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e8cb218-c3d6-466c-e73a-08dcdf1466a4 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 16:49:49.5527 (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: uHSpTre+9oTv7cL1X80OQs0EcAh6xzhDlRDUXgIL26JR1fEEmkUPY/fHSYW4QA/lzJ6RJcuQ+HvcfXpNl3hMB6VB6d3g3UZW79/+6eGYwSg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5606 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-27_06,2024-09-27_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409270121 X-Proofpoint-GUID: rrg8XDCJ8ElJnArhfExTkDqKwVNp1hR_ X-Proofpoint-ORIG-GUID: rrg8XDCJ8ElJnArhfExTkDqKwVNp1hR_ X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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~patchwork=sourceware.org@gcc.gnu.org When traversing gimple to introduce CO-RE relocation entries to expressions that are accesses to attributed perserve_access_index types, the access is likely to be split in multiple gimple statments. In order to keep doing the proper CO-RE convertion we will need to mark the LHS tree nodes of gimple expressions as explicit CO-RE accesses, such that the gimple traverser will further convert the sub-expressions. This patch makes sure that this LHS marking will not happen in case the gimple statement is a function call, which case it is no longer expecting to keep generating CO-RE accesses with the remaining of the expression. --- gcc/config/bpf/core-builtins.cc | 1 + .../gcc.target/bpf/core-attr-calls.c | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 gcc/testsuite/gcc.target/bpf/core-attr-calls.c diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc index 86e2e9d6e39..cdfb356660e 100644 --- a/gcc/config/bpf/core-builtins.cc +++ b/gcc/config/bpf/core-builtins.cc @@ -1822,6 +1822,7 @@ make_gimple_core_safe_access_index (tree *tp, tree lhs; if (!wi->is_lhs + && gimple_code (wi->stmt) != GIMPLE_CALL && (lhs = gimple_get_lhs (wi->stmt)) != NULL_TREE) core_mark_as_access_index (lhs); } diff --git a/gcc/testsuite/gcc.target/bpf/core-attr-calls.c b/gcc/testsuite/gcc.target/bpf/core-attr-calls.c new file mode 100644 index 00000000000..87290c5c211 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-attr-calls.c @@ -0,0 +1,49 @@ +/* Test for BPF CO-RE __attribute__((preserve_access_index)) with accesses on + LHS and both LHS and RHS of assignment with calls involved. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -dA -gbtf -mco-re -masm=normal" } */ + +struct U { + int c; + struct V { + int d; + int e[4]; + int f; + int *g; + } v; +}; + +struct T { + int a; + int b; + struct U u; + struct U *ptr_u; + struct U *array_u; +} __attribute__((preserve_access_index)); + +extern struct U *get_other_u(struct U *); +extern struct V *get_other_v(struct V *); + +void +func (struct T *t, int i) +{ + /* Since we are using the builtin all accesses are converted to CO-RE. */ + /* 0:3 0:0 */ + __builtin_preserve_access_index(({ get_other_u(t->ptr_u)->c = 42; })); + + /* This should not pass-through CO-RE accesses beyond the call since struct U + is not explicitly marked with preserve_access_index. */ + /* 0:3 */ + get_other_u(t->ptr_u)->c = 43; + + /* 0:2:1 */ + get_other_v(&t->u.v)->d = 44; +} + +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:3\"\\)" 2 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:0\"\\)" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:2:1\"\\)" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type \\(struct T\\)" 3 } } */ +/* { dg-final { scan-assembler-times "bpfcr_type \\(struct U\\)" 1 } } */ +