From patchwork Tue Jul 30 15:36:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 94787 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 4F3F2385DDC8 for ; Tue, 30 Jul 2024 15:38:20 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id DB0043858289 for ; Tue, 30 Jul 2024 15:37:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB0043858289 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 DB0043858289 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=1722353849; cv=pass; b=huNvjX7VhQvjHw4o/NofoPIjla9A/UbVf3bdUboG8DQj1EWupJonGNsbKfflQuLOz0FkqCtQrHiT8VFep2j6P8jWB9MlOR7EP7tgeQSp/c9lxCoZqsG59SaecMV6Ns362+NmswNVylvDKLFgKSVFk2YgQ1IE+s+YF+nA1QjWgBA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1722353849; c=relaxed/simple; bh=848Mg5fLqTONhzwBzM/qCU4epijmsNU9oHo0WXiKWvc=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=Pn51KrErUx6glryplA9fKXVou1ciyaTv+K9acI/F/Ffkq/z4esSjkXEHyLNwAEHcSlErnK2ifzrN78MB5N6EHa61lO+ZRX0cSHqa/K+BjmJWPt6IlFNFaRjpUpwaXeNIjTUpxuW3MlrZzunLhtYydEcT85tX+Sjga1F81Pe+H4o= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46UFMXtx024750 for ; Tue, 30 Jul 2024 15:37:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=0r2oEMzJJQZBqTsSeASyR6Fx7ZvtibyUOC5mQ3qQtO0=; b= gvidIS9jH1V8Ny9iJNrcDiETaJOtfLpjKSxyX9FPhsNMQtsn2PC04lqMIZYfKt5h VRo5E4A5MIv7DYcxaZQIozH3C6NeC3b8JgkkMcfgZQAd6LY6u82cRAsqddTaebHY mssI+x+56ptDsPfsviB5DGN5gJykJVGd8kLODO/HqgYl7ITAhvtDnXI/LPvbu2yX opBkC5sS00Ym7zbSPtZcLH7FhlPMP6jjz+4xr0j4PcXxvvDJXA1G4W4rAZCcOvI8 AL2WH/C00FyTrnKMnRcn04t0T/fPrfy98yNA+9mSwg5cU5qGQs8oxSxTYr07w2r5 PIFDemL318KjG7Ulkkeztw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40msesnaww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 Jul 2024 15:37:25 +0000 (GMT) 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 46UFQIen037975 for ; Tue, 30 Jul 2024 15:37:25 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2044.outbound.protection.outlook.com [104.47.70.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40pm83eapx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 Jul 2024 15:37:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rYW6heZhu/u2qOylobA8sZ4XdkH+wqPndff76vqrvO3XcgtqkW+3BnFDeuEQ957fmWFJJHITybkVz5PaiWfvIUb1OAsUIOpdCE+8hDyldscy8IiA+E50D+QhbmDBd2OfqJPciWHmrzlLRNOIrjGr/l+94nHgOzIH659GB957qqKhn1RymNq5E2LNmjEqnxdk8zKZ9w1v2jIlKiIB87kC1BO/1dmtYJa/npRbv99N/wXRDnJIna0FJ0KlJO9LhYankseZUSPf9j/1756uOBbOXKZ5AhQCZqMuba+He7kortP222ElLlcdnUyzllJL7UrJXAs2uRiFKszY2FcCd8JFZw== 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=0r2oEMzJJQZBqTsSeASyR6Fx7ZvtibyUOC5mQ3qQtO0=; b=L8ZyeHq1LG5QAbr8/oOTKnHOve49roMrPkuq9sYpapxGTTGS2AiNwdkHA66i3LvLfFKdpn/Zwhw+jw3ajVwj/1K7CQ1gIg4FvG7JWxC8IpKe9bsMZQLRJHJ4Ikj+kqJlC2Mo4UhGVWU3rA58hXmsKiH1fF/d1TT4LqqfGmienSP33pRDpkjA+GvwlQMOAebIzGDZedjO+ddsTFtMTOBbbUpO0ArTBSDoEYcjKYVhFGS31d2lGO5QVjslpZcIjZIhLQ1B+FLuPyJICIEDu6Ppzkurk866sfW4+gT9wXUj5SgwOl5GZeJJUlVxqYHqXSTooGOeWajBSZZCqVJAAthqtQ== 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=0r2oEMzJJQZBqTsSeASyR6Fx7ZvtibyUOC5mQ3qQtO0=; b=EkfhN79YEhFDtkdn+8UA6MVH0/Fr2VJAg2fgFS4Ho2wNc1bu+/s3HO5CU1kt+zvYKzGDZSFV9Ivwrtr3FEt1V34i5jds84Pp2XKEuBvPRkoZwQ/XJNfmxIexxKcvWhrhKUApmbV7HV2ZxwIoGd3WZ0WtKcxrfOJYR5kTfpXw5AE= Received: from MW4PR10MB6608.namprd10.prod.outlook.com (2603:10b6:303:22e::8) by DM4PR10MB7476.namprd10.prod.outlook.com (2603:10b6:8:17d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Tue, 30 Jul 2024 15:37:22 +0000 Received: from MW4PR10MB6608.namprd10.prod.outlook.com ([fe80::b53a:ccc1:c190:c5df]) by MW4PR10MB6608.namprd10.prod.outlook.com ([fe80::b53a:ccc1:c190:c5df%6]) with mapi id 15.20.7807.026; Tue, 30 Jul 2024 15:37:22 +0000 From: Nick Alcock To: binutils@sourceware.org Subject: [PATCH 02/19] libctf, dedup: drop unnecessary arg from ctf_dedup() Date: Tue, 30 Jul 2024 16:36:50 +0100 Message-ID: <20240730153707.168357-3-nick.alcock@oracle.com> X-Mailer: git-send-email 2.45.2.276.g4ac82df17e In-Reply-To: <20240730153707.168357-1-nick.alcock@oracle.com> References: <20240730153707.168357-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0157.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:188::18) To MW4PR10MB6608.namprd10.prod.outlook.com (2603:10b6:303:22e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR10MB6608:EE_|DM4PR10MB7476:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ea08d48-910e-4bc7-199f-08dcb0ad80f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 8MAT2ZXXl7fr65P10kU9PDb4X8GDJtWB2JRtOJnH789fal8WoefBhuoFturqJCuNsKZ36/x3GTCLgIVCkIODBpNVvrsYRo//3Sf2D4OqBzRucsxQRpn+dqCs+tgvXHVYKWOR9ZPriIlyMPXAum5AC8wbPSrlvEGc5q0BoGXMjeiLPPUNtSSq0HVzKowOiwU9xTXwF3SrpIalO9QORafO4xFfmYjwpzk30jFJR2OiIUG3mVBRbiLzSMXIzFdWy2JXS+9tMMKxyxBy925HhlQv1CVoxbzADlrxc1+vqeoSeLqLZsvZ3vAVa1jwfZLSFHsKUAfWG97dUFf2+gOWOAORREoFwmKLPx5bopqyJzNoTCvJH25mxCtHYkSBeXHtjLfcV79DgP1zKbi8Ntuq9g5zC0qjlC0K1PCdl3Z7Nx2JSQevxI/wUrdUJnYp+YwessAPlLkP8aSaUdgKvONpQz+WlsLikmsjidRZhRwgqcJVGVKKsiiUnoruyga6/FY+7UhFZXG3X2MwOxcvaA2eCeIdI47oAbSSOxt1mKmha6ZcMC0u+VFRtI7E+ts8HU9sWgh6S8nB+Q0S4R3TnmY3FGEdB1vKRLy+UfpTFROYXSFKCemU9e4F6lPxzDTA+S3HCWfkWGVsr7f3F+f7a8y1MB8V4sA+sh+9u+/hW6Vl6bj/sSMRK0ckXU9X89LwbgDSfdAhUHBbpQUTuwgGCWhuUv7YROIxFpjvQrcTDoQZsp4ssxVWVr0bPGJGm6ymsgyOycEBQ4RBNsO+K21wsVSdxJcrHOLfDKlyHfiK1y+DqiSamsKVXwP0n7qB5J4dNWLIY/tKKEpTUpsXE49kl4nkO6TYtCbyHXLtKqM9yKuCWKjmj6p5KblWtHhyX0727Ho1XvgewTfa3SnBxvPzkD/T8XKqfhkUMNT4aR+9f2SfWunqyA0PEUIVPZorxxzjJDH8kJ+gWBWhn/T4EqfwipBQti/QjGX/vwGU85k+KCuKTndfNyje/z7mFK2CivNEJHhD5GZsec5h01wGtU0zHa2fZMZAuZpjkj7SFXS3MTrTbxiWhAhqZl3jLxL5bRZl2Up4mS+AnXf2Kd6INRm+7dGcTY9nm9DqJklrThLAKUVrAZI37Y8ybAFd308cM5NG5LQnSTFMVul0R/Pwd44HuFgYxkuUzi0W3RrVPyMqsdZUimj6TE0KVazHkCo4rv+K77PvREU9Yo3ujWDC3t/rSgLnO1fDG72C2R0dMRCNdgseZwaPwvghB62iw2ZExIHoIpAOlR+d6QWQ4MmplT2cclihfAjX9IFe7RfxhZwTMhG32M3aKSkd8MiVUBfQv0hHQ32F0mEga8sk+4xEEflzyBGvFXM/FQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR10MB6608.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vNsAgyER81ThTuHM0BZe8DzsRFNQ18JC5TNWJfszz4SoTSXHZ9noOHA2qKji5FP21FYvICy8gcaiuQGh3d66jWVgYtzkvtdWZEtGqqyk0bfdsh6kXCG0sTr3T8zU+g9JzsruVzY6lgJpJtL0zqusry9frR9tiafxubcHe/aHMIMzDJpfnXTU/+vOCGBa0zLRZzXa+kMg/AnfydAB9s1IvNdCsOR4kQgDle7lqwUavchdF4qM/hThOpUsFSFxagPkAb2gkyGLNd9oxA6+U2PBLTmGy/8q0OEZb4NDdSvzDZhIbBerRTHRW6GBeYSlZmpVosRv9Lk8kufL61bjSopr2eCC854dx3fLX3Y37u9Jqa137JRUaJ3EJNjpDvx6p4HdXTGaqa8M1Roetokmlici9l1Xm6Ot6td3y++ObZWMA3AztwrO8uF1Z1N+TqDO7MX9y3ZnJjLKEiXLT99wacsRf8jqRmEpvAFHCfvT5s7xSy22u9uPOfIm27lMf3/kXpBGu+dViQu/DRqSSOpoRmolwo0izUYo70fQvpwScfcfDFuzxKMNueDgTKt5qRrjLFVklaXWh6xxycxUUVTOI0oAM6OywE+2otCt0JH3ETkaeI1bM5zYVKqCykFBOIULhdGRVPEkoCkZbzjzJ6lWAqtac6ueHykGQW46+IO0BFViMl7/LxCVwnbNTpMO5VbppAp/yqUCUK5Nzj08zSF6slQd9tvLPWKODQnY62DrCkFCFDn8v3WA63pZLHuKGYSRk1LJ3n0MVzuNagN/dRfsmzzsnlnRxX2Gz8lXDhlF7uavWpE11+RmrUaH2IN9YheA8B5esnEelDGObBAL4nAZczEGpZy/d/+VdhpFX4idCF60+vicp2rO5IggEKRLPfgBh1iFjmRP5tDDVFLBe3tI7Z4z74kxBS1DaA+6g/4/JdhmHGvPV0kddboIPmZcGUgdJNLYbluspBN3NfXH//eBRkwirGVGYs6iGqz85W/lyeY1wH7lqADYkpmRNs23wrzWUO0qVgsdNTdURzn7PEKqqf3vNObvEghFw6t8Avk50NY4Qmx9YAfXmWkcYg0yQbRIanmJ18QG7mph9CwsYwDe4ia/5wTKssDsiAvAObvxrMgAbH4+lb3WpCFPYvcaIuo5z5lOUqYgXW5TzMpcMSG+7Xb2sEptNs6AjuWuGO+hUjE7fPiSxTaI3MyDpHRRWJMpPGxYyz+rW0rMQxwvFv3n2lbaQQ3wujL4yk2Wff4dImmaitkyY5WWrm4vztXBicfssBYn+Tn9yAaGLlLzW08vyB97YjkLAODXpHMhaC2531/fuYkw0+xuahJL3lW5Hl6/KJBkjhdAE8RfgnM3/a+K0whpshaTwtGy9oqY8+YmJc9FsovlwSucSeVqVQL60kqlP2p3yKwJsYgsUajnf/wHobJl8x3WYR48RXBEkUfvI7wOKQnxxe6p8CfhYOATwPqGJl1icWQpk7APK0/kMhpQdEinQBT3ruztBNi5LxlRgc/aUz+sM5Gelt3Pu52tsfeBdahCVrAxFXsFaOpQRuh1UYvnv6LTIkqeF3T8zInvH5vwH83N72SLMTnZlBGypP2C3gL/x7nv9pMWF0gftmDpGQ25eQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1rnt+tBr+tc0yJQeaxcJdIyJUYE6O7OSq43cwbB0wy+6EQKuieO1Ld2IQknzzNzYNsnOQlUr5P5osk8bwNnJpnOAmluLdmKZoFIOEcYap/znhw40F/qqVD+CldsczxhprflwvTd24SM/NynxBKHxFHU1hljnZMJbMZeH/64/dEFe7TuvvuCtubH3e6AJ0O+8bTxzB6UoRfu/OR6rRT/FLadl4Pyu3lh9krdmfOoP+uCDXrirOTxvuIW0Knf/A1Ckrghs1VbvXjGZ6PxggSnPetwN+QgfH/6gVlf2rP8vtFV5owzU1CvcuvOed0KFdAWwvjmAl0RRUgItcRE0HI5Xdgj8aeFeB7BfVHgWUXmqEZU+YRZuZ32zkPh48Hdi04swsE21cnYbKt4LtmqvatixTySjm6UqXDvZNowsJyjVgspB0VvW7/hI4Ry1mNcA12Q7uAnXdvg6H4P5/lNcfQLvr8DU4z8PbDPQNQwj8gpv+H5fd+yxm6AQWwbJvy7p+zYzk9IGIuDLy1EAIjEK49PAtC8JZNJVTydXSsaxD9oNbE21m49ZKPZvr1rr5Zj5ZrHLQ1UPHppiV4qb3ZfEUXDnbRbJhlVgQg9Ay8vFQ6feSrc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea08d48-910e-4bc7-199f-08dcb0ad80f0 X-MS-Exchange-CrossTenant-AuthSource: MW4PR10MB6608.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 15:37:22.0858 (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: TDXfC6CfSHhMreVLJpe5qgeeHDnytwO61gVTlfRYSOS6GzkpFfcENUIoIo+zjj57LasDND3soPjACRz10N42zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7476 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-30_13,2024-07-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407300106 X-Proofpoint-ORIG-GUID: tqyhldOulRu142xs_7ArEhw5TmxV_KsR X-Proofpoint-GUID: tqyhldOulRu142xs_7ArEhw5TmxV_KsR X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org The PARENTS arg is carefully passed down through all the layers of hash functions and then never used for anything. (In the distant past it was used for cycle detection, but the algorithm eventually committed doesn't need to do cycle detection...) The PARENTS arg is still used by ctf_dedup_emit(), but even there we can loosen the requirements and state that you can just leave entries corresponding to dicts with no parents at zero (which will be useful in an upcoming commit). libctf/ * ctf-dedup.c (ctf_dedup_hash_type): Drop PARENTS arg. (ctf_dedup_rhash_type): Likewise. (ctf_dedup): Likewise. (ctf_dedup_emit_struct_members): Mention what you can do to PARENTS entries for parent dicts. * ctf-impl.h (ctf_dedup): Adjust accordingly. * ctf-link.c (ctf_link_deduplicating_per_cu): Likewise. (ctf_link_deduplicating): Likewise. --- libctf/ctf-dedup.c | 58 +++++++++++++++++++++------------------------- libctf/ctf-impl.h | 4 ++-- libctf/ctf-link.c | 4 ++-- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c index dd234945462..6c58daae324 100644 --- a/libctf/ctf-dedup.c +++ b/libctf/ctf-dedup.c @@ -485,9 +485,8 @@ ctf_dedup_sha1_add (ctf_sha1_t *sha1, const void *buf, size_t len, static const char * ctf_dedup_hash_type (ctf_dict_t *fp, ctf_dict_t *input, - ctf_dict_t **inputs, uint32_t *parents, - int input_num, ctf_id_t type, int flags, - unsigned long depth, + ctf_dict_t **inputs, int input_num, + ctf_id_t type, int flags, unsigned long depth, int (*populate_fun) (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, @@ -552,8 +551,8 @@ ctf_dedup_record_origin (ctf_dict_t *fp, int input_num, const char *decorated, static const char * ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, - uint32_t *parents, int input_num, ctf_id_t type, - void *type_id, const ctf_type_t *tp, const char *name, + int input_num, ctf_id_t type, void *type_id, + const ctf_type_t *tp, const char *name, const char *decorated, int kind, int flags, unsigned long depth, int (*populate_fun) (ctf_dict_t *fp, @@ -711,9 +710,8 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, case CTF_K_POINTER: /* Hash the referenced type, if not already hashed, and mix it in. */ child_type = ctf_type_reference (input, type); - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, input_num, - child_type, flags, depth, - populate_fun)) == NULL) + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, child_type, + flags, depth, populate_fun)) == NULL) { whaterr = N_("error doing referenced type hashing"); goto err; @@ -740,7 +738,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, ctf_get_ctt_size (input, tp, &size, &increment); ctf_dedup_sha1_add (&hash, &size, sizeof (ssize_t), "size", depth); - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, input_num, + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, child_type, flags, depth, populate_fun)) == NULL) { @@ -773,7 +771,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, goto input_err; } - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, input_num, + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, ar.ctr_contents, flags, depth, populate_fun)) == NULL) { @@ -784,7 +782,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, depth); ADD_CITER (citers, hval); - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, input_num, + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, ar.ctr_index, flags, depth, populate_fun)) == NULL) { @@ -811,7 +809,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, goto input_err; } - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, input_num, + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, fi.ctc_return, flags, depth, populate_fun)) == NULL) { @@ -841,8 +839,8 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, } for (j = 0; j < fi.ctc_argc; j++) { - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, - input_num, args[j], flags, depth, + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, + args[j], flags, depth, populate_fun)) == NULL) { free (args); @@ -900,8 +898,8 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, #ifdef ENABLE_LIBCTF_HASH_DEBUGGING ctf_dprintf ("%lu: Traversing to member %s\n", depth, mname); #endif - if ((hval = ctf_dedup_hash_type (fp, input, inputs, parents, - input_num, membtype, flags, depth, + if ((hval = ctf_dedup_hash_type (fp, input, inputs, input_num, + membtype, flags, depth, populate_fun)) == NULL) { whaterr = N_("error doing struct/union member type hashing"); @@ -990,8 +988,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, /* Hash a TYPE in the INPUT: FP is the eventual output, where the ctf_dedup state is stored. INPUT_NUM is the number of this input in the set of inputs. - Record its hash in FP's cd_type_hashes once it is known. PARENTS is - described in the comment above ctf_dedup. + Record its hash in FP's cd_type_hashes once it is known. (The flags argument currently accepts only the flag CTF_DEDUP_HASH_INTERNAL_CHILD, an implementation detail used to prevent @@ -1011,9 +1008,8 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, static const char * ctf_dedup_hash_type (ctf_dict_t *fp, ctf_dict_t *input, - ctf_dict_t **inputs, uint32_t *parents, - int input_num, ctf_id_t type, int flags, - unsigned long depth, + ctf_dict_t **inputs, int input_num, ctf_id_t type, + int flags, unsigned long depth, int (*populate_fun) (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs, @@ -1103,7 +1099,7 @@ ctf_dedup_hash_type (ctf_dict_t *fp, ctf_dict_t *input, Hash this type, and call ourselves recursively. (The hashing part is optional, and is disabled if overidden_hval is set.) */ - if ((hval = ctf_dedup_rhash_type (fp, input, inputs, parents, input_num, + if ((hval = ctf_dedup_rhash_type (fp, input, inputs, input_num, type, type_id, tp, name, decorated, kind, flags, depth, populate_fun)) == NULL) return NULL; /* errno is set for us. */ @@ -1911,13 +1907,11 @@ ctf_dedup_conflictify_unshared (ctf_dict_t *output, ctf_dict_t **inputs) return ctf_set_errno (output, err); } -/* The core deduplicator. Populate cd_output_mapping in the output ctf_dedup - with a mapping of all types that belong in this dictionary and where they - come from, and cd_conflicting_types with an indication of whether each type - is conflicted or not. OUTPUT is the top-level output: INPUTS is the array of - input dicts; NINPUTS is the size of that array; PARENTS is an NINPUTS-element - array with each element corresponding to a input which is a child dict set to - the number in the INPUTS array of that input's parent. +/* The core deduplicator. Populate cd_output_mapping in the output ctf_dedup with a + mapping of all types that belong in this dictionary and where they come from, and + cd_conflicting_types with an indication of whether each type is conflicted or not. + OUTPUT is the top-level output: INPUTS is the array of input dicts; NINPUTS is the + size of that array. If CU_MAPPED is set, this is a first pass for a link with a non-empty CU mapping: only one output will result. @@ -1927,7 +1921,7 @@ ctf_dedup_conflictify_unshared (ctf_dict_t *output, ctf_dict_t **inputs) int ctf_dedup (ctf_dict_t *output, ctf_dict_t **inputs, uint32_t ninputs, - uint32_t *parents, int cu_mapped) + int cu_mapped) { ctf_dedup_t *d = &output->ctf_dedup; size_t i; @@ -1973,7 +1967,7 @@ ctf_dedup (ctf_dict_t *output, ctf_dict_t **inputs, uint32_t ninputs, while ((id = ctf_type_next (inputs[i], &it, NULL, 1)) != CTF_ERR) { if (ctf_dedup_hash_type (output, inputs[i], inputs, - parents, i, id, 0, 0, + i, id, 0, 0, ctf_dedup_populate_mappings) == NULL) goto err; /* errno is set for us. */ } @@ -3085,7 +3079,7 @@ ctf_dedup_emit_struct_members (ctf_dict_t *output, ctf_dict_t **inputs, OUTPUT, on which the ctf_dedup function must have already been called. The PARENTS array contains the INPUTS index of the parent dict for every child dict at the corresponding index in the INPUTS (for non-child dicts, the value - is undefined). + is undefined and can just be left at zero). Return an array of fps with content emitted into them (starting with OUTPUT, which is the parent of all others, then all the newly-generated outputs). diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h index 0a362b6b17c..cd93a187aca 100644 --- a/libctf/ctf-impl.h +++ b/libctf/ctf-impl.h @@ -715,11 +715,11 @@ extern int ctf_add_funcobjt_sym_forced (ctf_dict_t *, int is_function, extern int ctf_dedup_atoms_init (ctf_dict_t *); extern int ctf_dedup (ctf_dict_t *, ctf_dict_t **, uint32_t ninputs, - uint32_t *parents, int cu_mapped); -extern void ctf_dedup_fini (ctf_dict_t *, ctf_dict_t **, uint32_t); + int cu_mapped); extern ctf_dict_t **ctf_dedup_emit (ctf_dict_t *, ctf_dict_t **, uint32_t ninputs, uint32_t *parents, uint32_t *noutputs, int cu_mapped); +extern void ctf_dedup_fini (ctf_dict_t *, ctf_dict_t **, uint32_t); extern ctf_id_t ctf_dedup_type_mapping (ctf_dict_t *fp, ctf_dict_t *src_fp, ctf_id_t src_type); diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c index 801b6ee599d..42b2911e4f2 100644 --- a/libctf/ctf-link.c +++ b/libctf/ctf-link.c @@ -1242,7 +1242,7 @@ ctf_link_deduplicating_per_cu (ctf_dict_t *fp) dictionary. */ ctf_cuname_set (out, out_name); - if (ctf_dedup (out, inputs, ninputs, parents, 1) < 0) + if (ctf_dedup (out, inputs, ninputs, 1) < 0) { ctf_set_errno (fp, ctf_errno (out)); ctf_err_warn (fp, 0, 0, _("CU-mapped deduplication failed for %s"), @@ -1401,7 +1401,7 @@ ctf_link_deduplicating (ctf_dict_t *fp) if (ninputs == 1 && ctf_cuname (inputs[0]) != NULL) ctf_cuname_set (fp, ctf_cuname (inputs[0])); - if (ctf_dedup (fp, inputs, ninputs, parents, 0) < 0) + if (ctf_dedup (fp, inputs, ninputs, 0) < 0) { ctf_err_warn (fp, 0, 0, _("deduplication failed for %s"), ctf_link_input_name (fp));