From patchwork Sat Nov 25 09:47:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jose E. Marchesi" X-Patchwork-Id: 169688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1836349vqx; Sat, 25 Nov 2023 01:47:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHAwSOgWsRr7Vf7WDEUpY96HkAP+j9eLvfzXUWYtnvwqMHh1BbLWPRPnNnJZCK/Du77+GAR X-Received: by 2002:ae9:f70b:0:b0:76d:bc1b:c491 with SMTP id s11-20020ae9f70b000000b0076dbc1bc491mr5635519qkg.14.1700905678180; Sat, 25 Nov 2023 01:47:58 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1700905678; cv=pass; d=google.com; s=arc-20160816; b=JaGYmGF62sGH9wZz1rZ5EiKbayz86CBAo8Yma9JwHsYt0IDjdEk7jjDRdHYCiLntNJ 85yApBme5fV1Ok0U+RDi4lZSOfYHGwYLe+qikE3rPfbl4sLTg8/gA8osdF0ORdskGvlO 1ijpi+ScXoN989mnlOP3ImnbdjKWqeePQ631LHCnRsZenssr88x4sRbbaEi9kdqEYkm0 WvEQ6EF5pmJ72XyM2ka6cW5ncnI9xUb0duO3zSnR1pLnc0OwVVG5s65GJU27nUX4SyGx vYYRXq79Q9Sva2NTIFjMFh+sVL+0r/sf/OmTMGANptJ2Mton1rcz5s+gf1aE4S+Fzvt2 VmPQ== 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=1jKRp/w567TbQmLJF+dxJctu/5C8lTwTXsqaADkCXyQ=; fh=C4nEn4uRKApr1WsFtLyJD8L5BeRuRc+JFyqoopFjd9M=; b=e9dlSw1YGNyMzyZ2E2DbSSZ+7EmxqKF1ITTPkHCjtKumX4thfvKmUHd3hDE1lyWBaQ EM6wlglBySo58t5jQ6QX1ziFAGij0mwTDbTES75PupUF2oKpyNvN/SckW7ek9e879B/8 3tCfVqfkcUQ/1Q7/C0x1shOCTVEhXcHUB4jh7FCctc1pNlzPqxQeOZwZb8Fyjh3CADvy Gil0YBGY6N/x+IVTQ2d/L692jklpH8SI3hCLZBjsT9JaUcHkYrhF/vArNnHptA0NywL1 khn9FSWJjr+A9C7l/mryhxeUT0hV2C/PAJTpmwZNh39ORAO8yvJbAqjGQLNNqKQI/G7V WnlA== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=cTR3C1fT; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vYaM/NQG"; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c5-20020a37e105000000b0077d6aa47a69si4677324qkm.493.2023.11.25.01.47.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 01:47:58 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=cTR3C1fT; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vYaM/NQG"; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 EC39338582B8 for ; Sat, 25 Nov 2023 09:47:57 +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 4DF923858C62 for ; Sat, 25 Nov 2023 09:47:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DF923858C62 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 4DF923858C62 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=1700905654; cv=pass; b=qq9BeHCXRUTFZfZ9tj+Pfh255gS2zJeP7TaEHvggdihM4zOR6IuTLcUkEhTaUqQuU5+kw8uARrxw5711Hzzt72Uv6lPk2ljL7ZXl2hTnlxVPXHzeNWyCt93wEVpPyGSzJErYXho3LDFOSAXfTNkegEK/qVOKWzX8xL56kRgd68Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700905654; c=relaxed/simple; bh=vYmJ7+qH8QYTbjA9hIv204VQOjlbbN3HtB+aVhb3zoo=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=UDc1ZO2deTfC14fd11CEky6XFRmOyC7taq7YzyiB9qsFYIMV0SBZBMcaQHUHF+hWZaZN2H5UeSG+RRpzo/iJAccUA+hbtV5Vzku+1poVUKJ+9qeB3nAoTlwuUs0oJT3egCLNsuTxmgW9i91XzYnhJ66QNMA3bdXSr/lh9AeZWc8= 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.17.1.19/8.17.1.19) with ESMTP id 3AP8XkOC024751; Sat, 25 Nov 2023 09:47:29 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=1jKRp/w567TbQmLJF+dxJctu/5C8lTwTXsqaADkCXyQ=; b=cTR3C1fTURXc/xMDOWi79waPKwBRFPYhdiMqLW1Cx4irdXbK1DLO/RcPQOf+G4zQqWmu wr7Sr1NGCVZcuGOvORyesPFGQIcBxM2Dqu+IxgLeDJvsS6lEHAVn7+R/kQSlFMM4DRGK h8pC5p0g/HKaegxA5bBVi+lZb6PY+waFIKAaUUawgQ8mNA6aPfzcWKZuRursxq99LZ9p ZZj6Gh2P7pMicAKYRvzxcHAVJLVwwH8Z5f8StkFVRdTnym/+ze2/1rkWXf9Lppz+KWQ3 Hvl95cP0fnJJBjPj1DOPoaICuWRu9b7u90Z7P1aCUm/Pzs+LlhvPjVGfbZzDklbe4Rx2 TQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3uk8yd08hx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 25 Nov 2023 09:47:29 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3AP8t9Si001389; Sat, 25 Nov 2023 09:47:28 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3uk7c9jaaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 25 Nov 2023 09:47:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D/Vs2w4oZ/K8AMu8xPYfQPRt0sE8FFHQRkfjtSbRUt+WyqX8hlg9SZmMQElf09gsV9NWJZajeZXrZ7WD+yNKpT3ws43AhELG6r893U3+224sM3f36279yKGNbYmbPEMr5t66IlNLlgSrtl5fSjMgVVQ23bhyneoVFyacM81v/eeFZ3fCJIvd+EqX7kxD0OxDAH0Z0m2lbGCbNwPIUpF7zBKpm9m8uO9+0fM0vyZAOscpvvJdPVHAUBbk8oUzcCmvxFUu1xkwMPjWxj6bRwYzYEbu75/nT91YeszxoDKdE5uunf7w0IdoQIk/md4g2B1v+QHbprX0Jp2Cnztm4/65eA== 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=1jKRp/w567TbQmLJF+dxJctu/5C8lTwTXsqaADkCXyQ=; b=ksSrGcsKTTXtOsNJ6GPJ13fmyxQyjfgqPFx6s2gawn0ToV/MIDhFFU1dU2tK0h2PXdvbm3NmUXNOuOUgrjZOzJUZE4nV9znvu08OjjuT/Jcxu1hooiW9/UThqCQ0qVk/WpcbioYXf8mZ+Dx94RtCmB3Vwko7s07ReRwhK2KaB3m6eDPCE0Gj3PPj6Pmei9yF3MHR61Hk67No1S4tzeXGF5rs54KIroJ1E7CC5czl8ZQqepOQrbIl81Ao9fRGYuJfA0qQlOMp56BYAU0TAPgjQY+NpHqgipT1ow2xKr8eU9KPSuMG8etuThEtBblb7Bntox1OyUIZhAX4ZUp9B0vWHA== 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=1jKRp/w567TbQmLJF+dxJctu/5C8lTwTXsqaADkCXyQ=; b=vYaM/NQGkj8vlrvoC/xdZaTQzZpCkIj0GYBqUL5lqFPywJTUHOK/x8NkmQHzqpSgUPeORlJGzhLuyWbVi0HIoG1Pl39RTyoyCtWziypcOEUBSNA1JWBXRk+8FDDo0zecC77Kb6fjgb7BFXsSaScXlu+eV1qR4JzobW2jYjvIeLQ= Received: from BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) by CY8PR10MB6873.namprd10.prod.outlook.com (2603:10b6:930:84::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.21; Sat, 25 Nov 2023 09:47:26 +0000 Received: from BYAPR10MB2888.namprd10.prod.outlook.com ([fe80::ba16:f585:1052:a61c]) by BYAPR10MB2888.namprd10.prod.outlook.com ([fe80::ba16:f585:1052:a61c%5]) with mapi id 15.20.7025.021; Sat, 25 Nov 2023 09:47:26 +0000 From: "Jose E. Marchesi" To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH] Emit funcall external declarations only if actually used. Date: Sat, 25 Nov 2023 10:47:21 +0100 Message-Id: <20231125094721.18913-1-jose.marchesi@oracle.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: FR2P281CA0144.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:98::18) To BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB2888:EE_|CY8PR10MB6873:EE_ X-MS-Office365-Filtering-Correlation-Id: d7838319-2378-4523-8f8e-08dbed9b87d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CMyVGhGQoQaiQEO19KQk3ZxbN3e2I/Q9l+7pTvOUogSsTEYeF6yajvWM+hcmmVs9a8JTmkecD+H6qhfpHb/R7Dc4AZlPZbxTQomH3f3vUaA6MttLrfO1pw1lYiwcn8P6b2fC6WeHzvamg9MO5EhbRdTm9FsxFwyCZZ0FLdcpzjpCPBFdsEgeJvrlWrd4/UVdbrqJtM+frPsNzH+7/2UADd1wi5Pzagqq/y+HvBXvJR9c2NNKiqsw8otMZiDZcV0wTiB1p2wtpVpKoOoCqom372TjsDdvW3i8IiWG9qFShXIDTpLPndb7zV9xMRnOYIsw9BdBbo8QfkGlfWMqO13TgTtvrU0CcLz4rQy0tTPJB3ojW7RmfOuB/xIB3UHJD9qGfhG5P4B8rDE0ttipt36AhPblj+mkAqcMuxKai2+VDRCWwx63y9viQH/JHcw78z+07feOyQ4SokVTuG0vusfyTQu76/zMdgqqkkQuvNKuYHP78OpKSqsOvVKu6aAWDW7EEUEFSisvDFLPc/Ie9RE7ZQFTGTfZO8HtkEi00GnRcN2841LLHyOwNMFIEI3gwyBsEHgZx5PRxPHpi1csUEhF9YDdeDn6tLR/+LlwkvKYSKX1EkSZvJdrC/xBFYR+T/7N X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2888.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(366004)(376002)(136003)(396003)(346002)(230922051799003)(230173577357003)(230273577357003)(451199024)(1800799012)(186009)(64100799003)(41300700001)(36756003)(5660300002)(2906002)(86362001)(84970400001)(6512007)(6666004)(6506007)(26005)(1076003)(83380400001)(478600001)(6486002)(8936002)(2616005)(38100700002)(6916009)(316002)(66946007)(66556008)(66476007)(4326008)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fjIm+y08lneDXhDu7wk+hld7ULNuZYADHaTNwv4RAQhoa0F1bltVwQtJ9INAc57ws6VQIZDboT+9xRjCpXErZwbrvBn/ZwBW51jhe0oGbuVRad15HiHxKP583dbUchXbFHolAuSarfRFU5CDPUNJ4q/Jt4KIhRhqK+0/eWshHL2cZ1x897zKyh3GWtSws/gwceYRE0fp+TNwARzFfoeOAnZ7yNQVVLaHOLYWEFQTo7/I+wGiQJPLXxVnCM1xh1+R4tuc6Hy2bSDR3927JxS1Hw/rbOzr+AyBNsn696zQgcglFrev2SNnaJ+aAcCAT2lOrVCKcgDzuh5pxtu7mK8Y2FszDkGbJr8RCn0Cdm5DT4Gaf/4nd62WVvwnAaEMSJ6h1YfNASq+wIMYkr0Njic8cM4+8X07t9Go7GwKWw1o7aEHGGB7OSaDOUqPfbdOfRCJbZTuBgRzqlCu5AVctkAddHs1PUohBiZJVOC4N3SsqFapwEXMoCqK8X7BTT/W7cmfkxH+L9p2jmou1M5mA18cXeN+z9fX144JZzCkio5fSamaPhVfhpJRFuo99Wi12hQvyc9w8XrlgEaXWCr/Ara7lh3B/Zy059iXdAjLV4VI+RWQ942OzGSC4iHreceMX/MKMI0YgktEjY9jsuDHdJEwhDCEc7vanmv/st8AMzDTX/IJ/AY72SZuywLOlBb2CoMmT3+4qKnmYf/2N/ztACPgZ+ucY7GfgWJvuQCBZnURtiLwYhHgEEPBtvvv/FXteqY5/W3zcxop8doJYR33P5fp+elC1rfQr5IVFDfRbX0Oo4RuGqDUC9uzvprxahRQ1+uR8RODhwVH1WHVSdv4o5MZtRVvMcyw4l0XaFummF0eQDKrwrEl5fPaM3L1xmz9Dd4G/Q5BFMdzAP3CGaNHbBjmFKMbpZHUpRe7sUJS5aO/TQLPr+DaaG7FA4dcEg6zHGsryhwfrC7WK1VSExvwXtvFXmT/KDoF8utQ44s/eMQTH5WLK3v5ElmUnPdegpXqJTa6f7Q20ycxGuRDB15gq5V3WwR5yI6erExdQ31kqEAVdlpJ/cC38BuGMvwLVhyvJFnQCWhylW14s5zaXhH3eXxSdM4oXS1EEbQeNPvWzFQg6gasI1CJMh4rjkb4eheBzfNZMMXyV0lDee6BsHJilbMgpyDFMUstYPftfKa0EQjyETxfFXcHIXJIoYtXYkzT/Qjw1DZoXIRb5f8l5ZCo5e4lHNChmRmHMfDgeRsiA+gK4Q7iBxSvUZEJSih8fl/mr+YTcNlgF4pYUuVogz7/2YqJmRwmqDVHGBRZiTYEQc2cNIJz84AQJozI/l+xrtGAhLLZZKb7rUOeh2lNYMoOUUsxa2/mzqyYdKyxPPlzu3lmlCvEUYcQzNgtQTohNzjygreR+EYcyqnmZahesQhVAKXlHdK15xfCnpX2PrpqlQ2g9CqaNW6gdkEGYFHS37WDU+7Ff9F+TL7ocSdjH9qtQGIHyBktS9xg2PuoeSD7wmTBmmIxzWjumpILiiDITkfWUQQs+yycd6WRkP5jXFF4bAUef1ECaNEJmFpoXVcrYTt0guUom/uY69MUk6g8UdLIfNjV3lEbAHizoW+IAcyraQSC2Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rne6t58ICCLPWXhfFAeH2cQXPqU1znmcBoYPVTeLU22usg8TgoWUpxEdDOdCkNHyn4yNdfRN+Dimd9o1UpAWNMo9d6B54CHRAPnbuuHn6IG4TPvFnbMnEtlD4YlraDc68F3p2BYgc0y9D37KB6/4P9GuI5F3OYCeCZhzq7gOeEDVIGW3IM+WJfmDSr7bPxMpahEcDCxtmPFClmQidIb4bFJvOSy8BjR/oo+FwcdsOwREw61OXWL9TQGY6TajfF6tQFLatqHg+DniTdVgLlhXzMoyJbfiA2ISymqtEi4N4vqoUvZD6eQUoCZChYPXEZmJWxLioO5VWVzndO8aKusro3em1Y+duPUdsaoCXibLSptytVUOiAyrfVA87BaSkjqMegZZSSPbCuQkegwfz8o++dwoZPBoD+aOBzFFlreaxCkMMOZfPaupeBLnC4BawoXJWfSJxfMwFnylf/80V4Q2FuCGwgH/H/zcY4VzjUMW7ewuHP1In1BAecAQ6XA3ssP/1RcGFvTzaOB/ccds/aqXVBVHxYnusE/rXyz676TwHk8DNAeVG6E4kqwd5rINZQtcgDsstiUiRRlQ9LAb0f3SBdKNT/7uHpr6IQUxSdJ3kannwCvS74Zx9DoQIOzWXMJ3dq/dVZWoQRdYJcuPsVxGIBmGLdkzLlYAuV2XNaFyyPNpO3/u1ePMKRE8W4KLnFnqTk35MyyN4f69+hXa+owI2RmA7Q4dJaYv1UhdL5IItT18epr+L+odlrrr9/LPv16vZKeRbuECPYqc9frggWJy8A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7838319-2378-4523-8f8e-08dbed9b87d8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2888.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2023 09:47:26.1658 (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: GeXZZb1qBxUtSdl3UfKLMTZXy/V6ZwIwleumymn47Fslfw6F7rNRQpbWDanz7pyGP12T2qR7W4H9TyasGBQMhIUOInq1OcZvwRwSgCWl2W0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6873 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-25_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311250070 X-Proofpoint-ORIG-GUID: ClfJAMUDxHmvHjDJaM7zQ7hUsA4Xtgsg X-Proofpoint-GUID: ClfJAMUDxHmvHjDJaM7zQ7hUsA4Xtgsg X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, 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: 1783528872273281630 X-GMAIL-MSGID: 1783528872273281630 There are many places in GCC where alternative local sequences are tried in order to determine what is the cheapest or best alternative to use in the current target. When any of these sequences involve a libcall, the current implementation of emit_library_call_value_1 introduce a side-effect consisting on emitting an external declaration for the funcall (such as __divdi3) which is thus emitted even if the sequence that does the libcall is not retained. This is problematic in targets such as BPF, because the kernel loader chokes on the spurious symbol __divdi3 and makes the resulting BPF object unloadable. Note that BPF objects are not linked before being loaded. This patch changes asssemble_external_libcall to defer emitting declarations of external libcall symbols, by saving the call tree nodes in a temporary list pending_libcall_symbols and letting process_pending_assembly_externals to emit them only if they have been referenced. Solution suggested and sketched by Richard Sandiford. Regtested in x86_64-linux-gnu. Tested with host x86_64-linux-gnu with target bpf-unknown-none. gcc/ChangeLog * varasm.cc (pending_libcall_symbols): New variable. (process_pending_assemble_externals): Process pending_libcall_symbols. (assemble_external_libcall): Defer emitting external libcall symbols to process_pending_assemble_externals. gcc/testsuite/ChangeLog * gcc.target/bpf/divmod-libcall-1.c: New test. * gcc.target/bpf/divmod-libcall-2.c: Likewise. * gcc.c-torture/compile/libcall-2.c: Likewise. --- .../gcc.c-torture/compile/libcall-2.c | 8 +++++++ .../gcc.target/bpf/divmod-libcall-1.c | 19 ++++++++++++++++ .../gcc.target/bpf/divmod-libcall-2.c | 16 ++++++++++++++ gcc/varasm.cc | 22 ++++++++++++++++++- 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/libcall-2.c create mode 100644 gcc/testsuite/gcc.target/bpf/divmod-libcall-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/divmod-libcall-2.c diff --git a/gcc/testsuite/gcc.c-torture/compile/libcall-2.c b/gcc/testsuite/gcc.c-torture/compile/libcall-2.c new file mode 100644 index 00000000000..b33944c83ff --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/libcall-2.c @@ -0,0 +1,8 @@ +/* Make sure that external refences for libcalls are generated even for + indirect calls. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -mcmodel=large" { target x86_64-*-* } } */ +/* { dg-final { scan-assembler "globl\t__divti3" } } */ + +__int128 a, b; void foo () { a = a / b; } diff --git a/gcc/testsuite/gcc.target/bpf/divmod-libcall-1.c b/gcc/testsuite/gcc.target/bpf/divmod-libcall-1.c new file mode 100644 index 00000000000..7481076602a --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/divmod-libcall-1.c @@ -0,0 +1,19 @@ +/* This test makes sure that no spurious external symbol declarations are + emitted for libcalls in tried but eventually not used code sequences. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=v3" } */ +/* { dg-final { scan-assembler-not "global\t__divdi3" } } */ +/* { dg-final { scan-assembler-not "global\t__moddi3" } } */ + +int +foo (unsigned int len) +{ + return ((unsigned long)len) * 234 / 5; +} + +int +bar (unsigned int len) +{ + return ((unsigned long)len) * 234 % 5; +} diff --git a/gcc/testsuite/gcc.target/bpf/divmod-libcall-2.c b/gcc/testsuite/gcc.target/bpf/divmod-libcall-2.c new file mode 100644 index 00000000000..792d689395a --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/divmod-libcall-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=v3" } */ +/* { dg-final { scan-assembler "global\t__divdi3" } } */ +/* { dg-final { scan-assembler "global\t__moddi3" } } */ + +int +foo (unsigned int len) +{ + return ((long)len) * 234 / 5; +} + +int +bar (unsigned int len) +{ + return ((long)len) * 234 % 5; +} diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 6ae35edc5ae..deb7eab7af9 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -2461,6 +2461,10 @@ contains_pointers_p (tree type) it all the way to final. See PR 17982 for further discussion. */ static GTY(()) tree pending_assemble_externals; +/* A similar list of pending libcall symbols. We only want to declare + symbols that are actually used in the final assembly. */ +static GTY(()) rtx pending_libcall_symbols; + #ifdef ASM_OUTPUT_EXTERNAL /* Some targets delay some output to final using TARGET_ASM_FILE_END. As a result, assemble_external can be called after the list of externals @@ -2520,8 +2524,17 @@ process_pending_assemble_externals (void) for (list = pending_assemble_externals; list; list = TREE_CHAIN (list)) assemble_external_real (TREE_VALUE (list)); + for (rtx list = pending_libcall_symbols; list; list = XEXP (list, 1)) + { + rtx symbol = XEXP (list, 0); + tree id = get_identifier (XSTR (symbol, 0)); + if (TREE_SYMBOL_REFERENCED (id)) + targetm.asm_out.external_libcall (symbol); + } + pending_assemble_externals = 0; pending_assemble_externals_processed = true; + pending_libcall_symbols = NULL_RTX; delete pending_assemble_externals_set; #endif } @@ -2594,8 +2607,15 @@ assemble_external_libcall (rtx fun) /* Declare library function name external when first used, if nec. */ if (! SYMBOL_REF_USED (fun)) { + gcc_assert (!pending_assemble_externals_processed); SYMBOL_REF_USED (fun) = 1; - targetm.asm_out.external_libcall (fun); + /* Make sure the libcall symbol is in the symtab so any + reference to it will mark its tree node as referenced, via + assemble_name_resolve. These are eventually emitted, if + used, in process_pending_assemble_externals. */ + get_identifier (XSTR (fun, 0)); + pending_libcall_symbols = gen_rtx_EXPR_LIST (VOIDmode, fun, + pending_libcall_symbols); } }