From patchwork Fri Feb 9 15:54:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 198957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp946685dyd; Fri, 9 Feb 2024 07:55:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKwgRhf0fIsGEkd7EZ3Op31lxSQEczLWz3TkQS6094gS+FaEn8fx2Bs3SzdOywzqguMJpx X-Received: by 2002:a05:620a:11a2:b0:785:752e:8584 with SMTP id c2-20020a05620a11a200b00785752e8584mr2200491qkk.1.1707494124571; Fri, 09 Feb 2024 07:55:24 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1707494124; cv=pass; d=google.com; s=arc-20160816; b=v12sYp3+fXXVjtcnJNj1Qs4XnYx7aOEN2OCQ06DXFNY6YsrX3vbS9qq8WmDBi4ezEz hqHC5lra4jYW3xhk8vujpHa3mXRJhD/J1yelrYAU8s04Xx/I/dRS8DqeSwQ0vxPvmc28 Y0vn7L7uejjFB59S8fZLuF7AY7JmBLPc1sfinQjRD12Q9fu6x5iXPFLBqDZxKMhg89bj q+pIbQ1674iH75K25MyIuRJkPITOL1uZKSu7vBw1nWmcKLi0I9tVSslXPElBvaDiUjUi pkpnaqTjXjy5stPJ0emXFigtLzIhGGaS42RxtQOYAmad1GiNMzl36lQqC4LHwQNjFEpL 9N5w== 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:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-signature:arc-filter :dmarc-filter:delivered-to; bh=MGC6C0sZKYOPwQAo3h6Nf4l/lFhhzCERxTC45epo1iA=; fh=cJJg6Ae8B5dwVof+1647bYwzZrlXMlw/ByXtlZjlhjk=; b=bvFUYysK3F4ZXQN1gm1/+y5H1DMXtIteRX+09IlVdQHh9NqkvXjvCCy6a1XMfCan/P lvAgylIdQVrU2xlkSU3RL7awDlnTYn/xugw7vKXGm05Pr4VNBjKJ8RKGcr10pZJloU37 SxN3shp6XoUXNedAYPsQqlDgkr5gLV1lzS9/Ihwg7ZL9yGudscKPiBtBiYnizGCZC67x ClmW3AiVj9fH9gS8qVhF2uQHLAvWKLkB1fmPGCEewfLmIiQhu/Cw3supi5tK2tg8boKT z2Bzq3EswXuou2JLwIWSRqEQulrc8PqWQ398HHKIBtq1Ov5SzIXhwl8AZtdBvzUEb39A Fz7w==; 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="mfWo/Vov"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CcMv4Bs6; 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 X-Forwarded-Encrypted: i=3; AJvYcCXsSDWAZXfEMIXdbc+6e0q9E04WOn3SZZLWycmF5xlZzNEAalM27knJgoUg2012+J/vL5X+nDc8RKnieBqw5fYQqMt0nA== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w9-20020ae9e509000000b007859b42dfa7si2225971qkf.308.2024.02.09.07.55.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 07:55:24 -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="mfWo/Vov"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CcMv4Bs6; 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 DB8A438582A7 for ; Fri, 9 Feb 2024 15:55:21 +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 6C1E5385840F for ; Fri, 9 Feb 2024 15:54:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C1E5385840F 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 6C1E5385840F 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=1707494073; cv=pass; b=g17rvlHFuX0ie1Cw8PeUQc5k1u4DhsyJqWrRwwLA/PumjBHYrn7fzQ1H5Oz32cN7d6Jaeplue8l5vUDGSYl8sH58fwt/hJFtsnOu7XLCKTPb4kAp0VUQowwLw2A0+NUrBlHUQYkb59XYyBMbRfO2EVus8KwroiAPPT9fHOweHiE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707494073; c=relaxed/simple; bh=VzpExqZHbepKVW1bxQtA10MU0l2s1C4upTfCdeclWsk=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=kmS8xHSXfqxx1Ook3TeJV7nA0IDXql0mKMrqn31skGFPzKSk1lZhrk1MnEMV34ln1fP+hIymbLCwdeqG2SmJtLAa5PoOlDd/yT7lLXw3wNdMbFT/AJdM/dahHawoFZkclVhvW01jBw6I0JBuqbYy8cT5brGP0gfYcO15PcKDjYI= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 419FYV9k027248; Fri, 9 Feb 2024 15:54:28 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=MGC6C0sZKYOPwQAo3h6Nf4l/lFhhzCERxTC45epo1iA=; b=mfWo/Vov/JOqJnqFdvS3ZtykiC1z89Qf4R8nwoks3R6P5QWM4zxeA8Z7Lnq+TBZRtW61 TLGfyITUVGGXWYbFkV5kLlQFZQGafh1Omc/ngm1T2egIO2oCxhYBf26akpX4ECotbOVS o4L20yGov1nZ/YXYrDJIGi4zpyeBduYU4/FDPratz61hw3nhqmQEZe9Co/qaRNYwGLa5 99e7Z9vFzKynMkJmlQocq6WlyYnCIZmsaoIN5PG51kI//SwR7BVucYmrS9i5amFlWBQo 6H/2QiNTbrGms+78vayADKr8JpO9jg+ppQQe+sG5MeYZ2fcFEc85Xdp/oaYKWf1HApc2 Pw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1cdd7s1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Feb 2024 15:54:27 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 419EauZn007087; Fri, 9 Feb 2024 15:54:26 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2040.outbound.protection.outlook.com [104.47.74.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxcs4jr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Feb 2024 15:54:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VdyuD7L9V/Tv57EMc5AQxU5SFMfS9YxEeds3lr94jWs56Cad4kqHYiw5OLsj/6Ea1QIqWiMzUGvvAoJLR8OiovfNh98QG/xyrozyOVu84FJ7deDPH3j+01x0Ch6j4nWNoerReY6HonooZx7KGCIU3+0EL/S7H1hZrzCBxwlSBTBBwH580RoUU4Aea2Y4gjgTc4o3/OGv3u43Wwtk0V5Qq8Xty7Bp9BNar0nAgRUKiPZMK6dtIYw7DzHKe8ifoHsd1Q2Rr69Uz+cU7UaPhBzxrcGMcWHUmNFRWDGsxeDWe3ju0u7Jao5EYdcFkPfwT7UT5iQ6QVw53F9TBz4PCHSmEw== 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=MGC6C0sZKYOPwQAo3h6Nf4l/lFhhzCERxTC45epo1iA=; b=oAzlUCvOGGqQYd0QDp4LmErVLnIoaryJkBGj+NA4ud68eX7eRfDp1iIF6pS4KAW9339ItrxFmy0PgAKdi/87cPXiWAQFrY5XB2DJ8ze2gLZfNd5bF8jnAbEQMSONr/pGoMFPUJkmSv6FhZln/7FnUKorKaauP7tnS0ErB+8RjnmUyeRVlC5qCLUntvQeHgnlwSvdbgu284lLkITnZksu1pbXmJX7YhN1onQRPYKFj4FHjG97p+9zqYa/Efztl0EhxnnJNLXbTHwtusHyMPczg/rthv2QsnmhPu6IsrK57sDJVnIeJDbuDO3FwkcHmDAfI2xv4llu6tFoJNZY+9a5GQ== 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=MGC6C0sZKYOPwQAo3h6Nf4l/lFhhzCERxTC45epo1iA=; b=CcMv4Bs6fF61P+27PPpDPy1mrpvoVnIlwngxSDAPlziKcxnNqDSkz/w2Iz7vorCv5DDsaLdqxHwV4wgNk+tuwqQ0kCCPdmYp01/D+W0t+IbBarvGZLv+cioAldqiVAY3nJiK+K4IxsfRozwXf9w32vEkGjJabau/vqPjIJXCbjs= Received: from CH3PR10MB7957.namprd10.prod.outlook.com (2603:10b6:610:1bf::19) by DS0PR10MB7955.namprd10.prod.outlook.com (2603:10b6:8:1b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.39; Fri, 9 Feb 2024 15:54:24 +0000 Received: from CH3PR10MB7957.namprd10.prod.outlook.com ([fe80::6234:e7a1:b517:c44]) by CH3PR10MB7957.namprd10.prod.outlook.com ([fe80::6234:e7a1:b517:c44%6]) with mapi id 15.20.7249.037; Fri, 9 Feb 2024 15:54:24 +0000 From: Qing Zhao To: josmyers@redhat.com, richard.guenther@gmail.com, siddhesh@gotplt.org, uecker@tugraz.at, jakub@redhat.com Cc: keescook@chromium.org, isanbard@gmail.com, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [PATCH v5 3/4] Use the .ACCESS_WITH_SIZE in builtin object size. Date: Fri, 9 Feb 2024 15:54:10 +0000 Message-Id: <20240209155411.160245-4-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240209155411.160245-1-qing.zhao@oracle.com> References: <20240209155411.160245-1-qing.zhao@oracle.com> X-ClientProxiedBy: SA0PR11CA0078.namprd11.prod.outlook.com (2603:10b6:806:d2::23) To CH3PR10MB7957.namprd10.prod.outlook.com (2603:10b6:610:1bf::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7957:EE_|DS0PR10MB7955:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d2235d2-6030-4d81-b37f-08dc29876306 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y2/eVTKyGZlObQ56QFV3CoSieSUfPaGhuECdVn1O2j2EaIu+qsknBONvGCkioYbO5Fj2xWLUZyjkAGm4qQ+LMLStKqVFLd3iTLBIgzQdzKGo6AaNiZAVX54AAOldLunNDDwfPGXsGCR0fHvlw1PUTuH6Py+IzqP0GGCpi5/1ET1yMfwwBb+iuPaZrbQglvc+iY2SKtNTI+8DsIasWOS6kd05vka0d1In439UzBrhdjBL2KAPNUNl2g6oqGOSvCXOcY644bxfy/MJRDP+O5s9ZTOUQgxdvYAVASFEtL1wzbWjeOUPFUnhfvsfk5jZb1S1WTTXOr9vB8048O/He4yx3lJILo7h8gJuzEq5wh1Liq0TAQ4RnbqEoJk6wyi0MnyoRatKt0BAj6GZSOpg6ZTC3HRrJfUJLcmOkVmUKcfOGze/wnPOEUvnjI04lVWokXtbtPYJtYtOVMtQJuG0MmYNx7HXaeauwiWzLEHs8CTl5ZymQuqmwWy2PwYQpOwtaZjAdc0Ria4YeZqX2T2MnA1+oS4d0GDGbjlNOAzDpqWyJVc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7957.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(136003)(366004)(376002)(39860400002)(396003)(230922051799003)(230273577357003)(1800799012)(64100799003)(451199024)(186009)(6506007)(6512007)(6666004)(41300700001)(84970400001)(2906002)(30864003)(5660300002)(44832011)(8676002)(8936002)(4326008)(36756003)(86362001)(66556008)(316002)(66476007)(66946007)(966005)(6486002)(478600001)(83380400001)(38100700002)(26005)(107886003)(1076003)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nbQ1FkeHTSgPRfvyDbRwd48Ka53FvjU/TdM0XptT50f5MiScnnN2zsGHEpCNSkREZ5ZGHUFAMQWX+Il6grytcILMSbaJO7MGquR7h4BXssufsv/dIUz60AkLglKcutOcHXOaexcrg1g1E9EQznOb5Cp145T3YNtVDHLQBxajea9elORKmZjRxHsyk5cJ3m+dtqskZaDhBzNU+mZw6Unyx/LkQLzycDbLlKzD0jzmZEpHXJ0Wk9fh2frss9RR4j8jHud02HepmpQuk9CNVino3Bi9HsB5Z0bAZGOkxYMHTIfcRbEmx4wUspjTX2AO1Gq3ZJh0mZMXXzG2APv+NjqEsjP7vtkf4Tj6Xr1w0o//GYIkqZyfpsSoFNGEefaWNTx/93UR8Q/2QQ/0mqb0QYod7sTNvHmojzZflFX0U0uxSYqrOw/QaVVUXcLQR9walB6Sk8nRVZ0eKdSQootO7IsM5jvTUMWlk3mWO2W6e05aR7+YZs30NBlDvHYn1kGzOAIsvKb5Wh9qEvgt4JoLJX6LXq1A9u6Fyyt87warMHppu7Djup648GtRXfft0UBYhvafXR1DTwD4mFecHwXZPLMGZHplWZAnPsVzPjtxB2WsCLo5Hoa+pQnSETLoNt69kODVtne5YBCpNXb/5T/M/XvKaoNJ6OQCcEmu+z3n44mAgIs9R9PiM80X3d+8ogjFnxnf7gSHKpBP8Hal/ySb8xcTxdoy8cmAwGqLw50cCFMTn39jBRzW2OYDBCOHFnf87KKcn3137RymLhEuEKq28UAEl4NU/i9iuLS+DlSVwfsBREJANhvgazZZ4L4FXO5heEU0OWA7Sq22fYW4xVjsioPL5RbjGZ0DTnXS4AUGB8H4CXEwOHb5I6uOyRzPHn25unWNjxeF/3OCo8pkFcms9TG/nqSbUuaLRpcHzZTxBfLjrbWf5ereVk4AUVZMckv1n0WY536QeYyNG0L4gCdz10nZtTbUeR819ZpA3jwyZTYT1Va9QsJhpAH7UzG+yCAXVs60pwrVd5+KMlXx01W8+icsxiTtoef1OJv+ctYSZvMN2Qwci9eRtWfHLQf+EAUIE/L+W38syOIYqlnsynld6wQxh8v0yJYEGSG97G6cTazCR5yVV73qYGOF4AeSgC28TnSqHhKOpFhEhtNmmZxATv3eVNa3x71+HNsGVGC9ZPw5ySp+YbEQw7AEuMDMQXviM8R3dVxumBglGhw+kR0uwCtJb+QLsihTtnWCldB41gLfSDscRQSUI0eZU2Gjc96cnmONpgCMoOg80J2t8GoA5Fw1gsv4SgQwFp6Y6uXIWsJVZLhFB29lmNnIGJuDNtotzs51ZiOh1dlpaqWKoXW9LhIURPAqcd6MqERubHE+oIbc/RuJVD/aL0JPzimpkYNV+WhzCPyEoXAxmyNNPBXNO1q1uFmcKVXtoh8/r/v2t/QbP12FENUDGzZnXbmtt4ORqdO0pQTVqXasJihc+xUCGI1af9AZGnCutDN8venAmpAne2sRT5DttVJeosajf4QNMAVrBjdgIgb+qcDVU7VUPzfG2fYPppZ1IWIpJbRydR0WYwYnQEpnTugBLxqv9vFLSgpn X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5wlOq0JGHhsSTkmOXnPO3Nna4tepQKOr7pvSXgELkn3URZH8gxceVtcFEluo6IWtalIzJ+AF6nYFdPJk2Si7NjUAteaVAa50TyLQRZA2HOcu8ThWGTOWaR68HNYOS1h7CcqGLqpi/EgNPULGPA+az0ZlYJN91A553gbzspI40zn2+DtnshjUh8OJmvyzYVRJdwUsn4vNggne2YrefEzeASt6ThnOTuazGxn9KoHqYsGPIcDVtV23IlJshCVFUZU9kyaqa+1cyLjYO3nUvzTMvJgM1a0phvfLwgnLW5XDOg1+sm2gb1MyBBa5znXPudColnm99GN6Jh1qwIsexD5UfGvqeEYUgl6mXSVLxUZAeh+oi3fOYUvx1uKaI9twffWOfU8Y78Bh5nnfYwhEf/hEPNf0vvrfHhVJkQCsCxr/5R4a93cncPRPLrCgRKG9sL8ScpS4zESMv7NlG7DYXMlDouYnyM2Rl07M4RwuBhZLUdfqcOXBYxgapIrPvbtY3nA6WXCV5DJeUlrVsp9O81W2GXbd1FmHYr8moUjg3x4qfc0q8Bow/ZvVWrCF/kR/hx3vnfL+wzyfctpLvX7X3l2nbKALArhdD5aNB9wKgKshAJQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d2235d2-6030-4d81-b37f-08dc29876306 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7957.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 15:54:24.0072 (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: oLgyS1JRrhfQVWZ9uSqnQXpeDMRYpe2SJKrrO8MSYZMAiXt4uPbJfoYl4T98UCioC8fcm+h7sg4W2tfQZLawbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7955 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-09_13,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402090118 X-Proofpoint-GUID: GLyArUrsasv7RQ3pv6gDC_vhGqjO_e7- X-Proofpoint-ORIG-GUID: GLyArUrsasv7RQ3pv6gDC_vhGqjO_e7- X-Spam-Status: No, score=-10.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_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: 1790437359215612205 X-GMAIL-MSGID: 1790437359215612205 gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test. * gcc.dg/flex-array-counted-by-4.c: New test. * gcc.dg/flex-array-counted-by-5.c: New test. --- .../gcc.dg/builtin-object-size-common.h | 11 ++ .../gcc.dg/flex-array-counted-by-3.c | 63 +++++++ .../gcc.dg/flex-array-counted-by-4.c | 178 ++++++++++++++++++ .../gcc.dg/flex-array-counted-by-5.c | 48 +++++ gcc/tree-object-size.cc | 59 ++++++ 5 files changed, 359 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/flex-array-counted-by-3.c create mode 100644 gcc/testsuite/gcc.dg/flex-array-counted-by-4.c create mode 100644 gcc/testsuite/gcc.dg/flex-array-counted-by-5.c diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-common.h b/gcc/testsuite/gcc.dg/builtin-object-size-common.h index 66ff7cdd953a..b677067c6e6b 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-common.h +++ b/gcc/testsuite/gcc.dg/builtin-object-size-common.h @@ -30,3 +30,14 @@ unsigned nfails = 0; __builtin_abort (); \ return 0; \ } while (0) + +#define EXPECT(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + __builtin_printf ("ok: %s == %zd\n", #p, p); \ + else \ + { \ + __builtin_printf ("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + FAIL (); \ + } \ +} while (0); diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-3.c b/gcc/testsuite/gcc.dg/flex-array-counted-by-3.c new file mode 100644 index 000000000000..0066c32ca808 --- /dev/null +++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-3.c @@ -0,0 +1,63 @@ +/* test the attribute counted_by and its usage in + * __builtin_dynamic_object_size. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +struct flex { + int b; + int c[]; +} *array_flex; + +struct annotated { + int b; + int c[] __attribute__ ((counted_by (b))); +} *array_annotated; + +struct nested_annotated { + struct { + union { + int b; + float f; + }; + int n; + }; + int c[] __attribute__ ((counted_by (b))); +} *array_nested_annotated; + +void __attribute__((__noinline__)) setup (int normal_count, int attr_count) +{ + array_flex + = (struct flex *)malloc (sizeof (struct flex) + + normal_count * sizeof (int)); + array_flex->b = normal_count; + + array_annotated + = (struct annotated *)malloc (sizeof (struct annotated) + + attr_count * sizeof (int)); + array_annotated->b = attr_count; + + array_nested_annotated + = (struct nested_annotated *)malloc (sizeof (struct nested_annotated) + + attr_count * sizeof (int)); + array_nested_annotated->b = attr_count; + + return; +} + +void __attribute__((__noinline__)) test () +{ + EXPECT(__builtin_dynamic_object_size(array_flex->c, 1), -1); + EXPECT(__builtin_dynamic_object_size(array_annotated->c, 1), + array_annotated->b * sizeof (int)); + EXPECT(__builtin_dynamic_object_size(array_nested_annotated->c, 1), + array_nested_annotated->b * sizeof (int)); +} + +int main(int argc, char *argv[]) +{ + setup (10,10); + test (); + DONE (); +} diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-4.c b/gcc/testsuite/gcc.dg/flex-array-counted-by-4.c new file mode 100644 index 000000000000..3ce7f3545549 --- /dev/null +++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-4.c @@ -0,0 +1,178 @@ +/* test the attribute counted_by and its usage in +__builtin_dynamic_object_size: what's the correct behavior when the +allocation size mismatched with the value of counted_by attribute? +we should always use the latest value that is hold by the counted_by +field. */ +/* { dg-do run } */ +/* { dg-options "-O -fstrict-flex-arrays=3" } */ + +#include "builtin-object-size-common.h" + +struct annotated { + size_t foo; + char others; + char array[] __attribute__((counted_by (foo))); +}; + +#define noinline __attribute__((__noinline__)) +#define SIZE_BUMP 10 +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +/* In general, Due to type casting, the type for the pointee of a pointer + does not say anything about the object it points to, + So, __builtin_object_size can not directly use the type of the pointee + to decide the size of the object the pointer points to. + + there are only two reliable ways: + A. observed allocations (call to the allocation functions in the routine) + B. observed accesses (read or write access to the location of the + pointer points to) + + that provide information about the type/existence of an object at + the corresponding address. + + for A, we use the "alloc_size" attribute for the corresponding allocation + functions to determine the object size; + (We treat counted_by attribute the same as the "alloc_size" attribute) + + For B, we use the SIZE info of the TYPE attached to the corresponding access. + + The only other way in C which ensures that a pointer actually points + to an object of the correct type is 'static': + + void foo(struct P *p[static 1]); + + See https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624814.html + for more details. */ + +/* in the following function, malloc allocated more space than the value + of counted_by attribute. Then what's the correct behavior we expect + the __builtin_dynamic_object_size should have for each of the cases? */ + +static struct annotated * noinline alloc_buf_more (size_t index) +{ + struct annotated *p; + size_t allocated_size + = MAX (sizeof (struct annotated), + (__builtin_offsetof (struct annotated, array[0]) + + (index + SIZE_BUMP) * sizeof (char))); + p = (struct annotated *) malloc (allocated_size); + + p->foo = index; + + /*when checking the observed access p->array, we have info on both + observered allocation and observed access, + A.1 from observed allocation: + allocated_size - offsetof (struct annotated, array[0]) + + A.2 from the counted-by attribute: + p->foo * sizeof (char) + + we always use the latest value that is hold by the counted-by field. + */ + + EXPECT(__builtin_dynamic_object_size(p->array, 0), + (p->foo) * sizeof(char)); + + EXPECT(__builtin_dynamic_object_size(p->array, 1), + (p->foo) * sizeof(char)); + + EXPECT(__builtin_dynamic_object_size(p->array, 2), + (p->foo) * sizeof(char)); + + EXPECT(__builtin_dynamic_object_size(p->array, 3), + (p->foo) * sizeof(char)); + + /*when checking the pointer p, we only have info on the observed allocation. + So, the object size info can only been obtained from the call to malloc. + for both MAXIMUM and MINIMUM: A = (index + SIZE_BUMP) * sizeof (char) */ + EXPECT(__builtin_dynamic_object_size(p, 0), allocated_size); + EXPECT(__builtin_dynamic_object_size(p, 1), allocated_size); + EXPECT(__builtin_dynamic_object_size(p, 2), allocated_size); + EXPECT(__builtin_dynamic_object_size(p, 3), allocated_size); + return p; +} + +/* in the following function, malloc allocated less space than the value + of counted_by attribute. Then what's the correct behavior we expect + the __builtin_dynamic_object_size should have for each of the cases? + NOTE: this is an user error, GCC should issue warnings for such case. + this is a seperate issue we should address later. */ + +static struct annotated * noinline alloc_buf_less (size_t index) +{ + struct annotated *p; + size_t allocated_size + = MAX (sizeof (struct annotated), + (__builtin_offsetof (struct annotated, array[0]) + + (index) * sizeof (char))); + p = (struct annotated *) malloc (allocated_size); + + p->foo = index + SIZE_BUMP; + + /*when checking the observed access p->array, we have info on both + observered allocation and observed access, + A.1 from observed allocation: + allocated_size - offsetof (struct annotated, array[0]) + A.2 from the counted-by attribute: + p->foo * sizeof (char) + + we always use the latest value that is hold by the counted-by field. + */ + + EXPECT(__builtin_dynamic_object_size(p->array, 0), + (p->foo) * sizeof(char)); + + EXPECT(__builtin_dynamic_object_size(p->array, 1), + (p->foo) * sizeof(char)); + + EXPECT(__builtin_dynamic_object_size(p->array, 2), + (p->foo) * sizeof(char)); + + EXPECT(__builtin_dynamic_object_size(p->array, 3), + (p->foo) * sizeof(char)); + + /*when checking the pointer p, we only have info on the observed + allocation. So, the object size info can only been obtained from + the call to malloc. */ + EXPECT(__builtin_dynamic_object_size(p, 0), allocated_size); + EXPECT(__builtin_dynamic_object_size(p, 1), allocated_size); + EXPECT(__builtin_dynamic_object_size(p, 2), allocated_size); + EXPECT(__builtin_dynamic_object_size(p, 3), allocated_size); + return p; +} + +int main () +{ + struct annotated *p, *q; + p = alloc_buf_more (10); + q = alloc_buf_less (10); + + /*when checking the access p->array, we only have info on the counted-by + value. */ + EXPECT(__builtin_dynamic_object_size(p->array, 0), p->foo * sizeof(char)); + EXPECT(__builtin_dynamic_object_size(p->array, 1), p->foo * sizeof(char)); + EXPECT(__builtin_dynamic_object_size(p->array, 2), p->foo * sizeof(char)); + EXPECT(__builtin_dynamic_object_size(p->array, 3), p->foo * sizeof(char)); + /*when checking the pointer p, we have no observed allocation nor observed + access, therefore, we cannot determine the size info here. */ + EXPECT(__builtin_dynamic_object_size(p, 0), -1); + EXPECT(__builtin_dynamic_object_size(p, 1), -1); + EXPECT(__builtin_dynamic_object_size(p, 2), 0); + EXPECT(__builtin_dynamic_object_size(p, 3), 0); + + /*when checking the access p->array, we only have info on the counted-by + value. */ + EXPECT(__builtin_dynamic_object_size(q->array, 0), q->foo * sizeof(char)); + EXPECT(__builtin_dynamic_object_size(q->array, 1), q->foo * sizeof(char)); + EXPECT(__builtin_dynamic_object_size(q->array, 2), q->foo * sizeof(char)); + EXPECT(__builtin_dynamic_object_size(q->array, 3), q->foo * sizeof(char)); + /*when checking the pointer p, we have no observed allocation nor observed + access, therefore, we cannot determine the size info here. */ + EXPECT(__builtin_dynamic_object_size(q, 0), -1); + EXPECT(__builtin_dynamic_object_size(q, 1), -1); + EXPECT(__builtin_dynamic_object_size(q, 2), 0); + EXPECT(__builtin_dynamic_object_size(q, 3), 0); + + DONE (); +} diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-5.c b/gcc/testsuite/gcc.dg/flex-array-counted-by-5.c new file mode 100644 index 000000000000..37fc215e5e5c --- /dev/null +++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-5.c @@ -0,0 +1,48 @@ +/* test the attribute counted_by and its usage in + * __builtin_dynamic_object_size. when the counted_by field is negative. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +struct annotated { + int b; + int c[] __attribute__ ((counted_by (b))); +} *array_annotated; + +struct nested_annotated { + struct { + union { + int b; + float f; + }; + int n; + }; + int c[] __attribute__ ((counted_by (b))); +} *array_nested_annotated; + +void __attribute__((__noinline__)) setup (int attr_count) +{ + array_annotated + = (struct annotated *)malloc (sizeof (struct annotated)); + array_annotated->b = attr_count; + + array_nested_annotated + = (struct nested_annotated *)malloc (sizeof (struct nested_annotated)); + array_nested_annotated->b = attr_count -1; + + return; +} + +void __attribute__((__noinline__)) test () +{ + EXPECT(__builtin_dynamic_object_size(array_annotated->c, 1), 0); + EXPECT(__builtin_dynamic_object_size(array_nested_annotated->c, 1), 0); +} + +int main(int argc, char *argv[]) +{ + setup (-10); + test (); + DONE (); +} diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc index 018fbc30cbb6..630b0a7aaa4b 100644 --- a/gcc/tree-object-size.cc +++ b/gcc/tree-object-size.cc @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "attribs.h" #include "builtins.h" #include "gimplify-me.h" +#include "gimplify.h" struct object_size_info { @@ -60,6 +61,7 @@ static tree compute_object_offset (tree, const_tree); static bool addr_object_size (struct object_size_info *, const_tree, int, tree *, tree *t = NULL); static tree alloc_object_size (const gcall *, int); +static tree access_with_size_object_size (const gcall *, int); static tree pass_through_call (const gcall *); static void collect_object_sizes_for (struct object_size_info *, tree); static void expr_object_size (struct object_size_info *, tree, tree); @@ -749,6 +751,59 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, return false; } +/* Compute __builtin_object_size for a CALL to .ACCESS_WITH_SIZE, + OBJECT_SIZE_TYPE is the second argument from __builtin_object_size. + the 2nd, 3rd, and the 4th parameters of the call determine the size of + the CALL: + + 2nd argument REF_TO_SIZE: The reference to the size of the object, + 3rd argument CLASS_OF_SIZE: The size referenced by the REF_TO_SIZE represents + 0: unknown; + 1: the number of the elements of the object type; + 2: the number of bytes; + 4th argument TYPE_OF_SIZE: A constant 0 with the TYPE of the object + refed by REF_TO_SIZE + + the size of the element can be retrived from the result type of the call, + which is the pointer to the array type. */ +static tree +access_with_size_object_size (const gcall *call, int object_size_type) +{ + gcc_assert (gimple_call_internal_p (call, IFN_ACCESS_WITH_SIZE)); + /* result type is a pointer type to the original flexible array type. */ + tree result_type = gimple_call_return_type (call); + gcc_assert (POINTER_TYPE_P (result_type)); + tree element_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (result_type))); + tree ref_to_size = gimple_call_arg (call, 1); + unsigned int type_of_size = TREE_INT_CST_LOW (gimple_call_arg (call, 2)); + tree type = TREE_TYPE (gimple_call_arg (call, 3)); + + tree size = fold_build2 (MEM_REF, type, ref_to_size, + build_int_cst (ptr_type_node, 0)); + + /* If size is negative value, treat it as zero. */ + if (!TYPE_UNSIGNED (type)) + { + tree cond_expr = fold_build2 (LT_EXPR, boolean_type_node, + unshare_expr (size), build_zero_cst (type)); + size = fold_build3 (COND_EXPR, integer_type_node, cond_expr, + build_zero_cst (type), size); + } + + if (type_of_size == 0) + return size_unknown (object_size_type); + else if (type_of_size == 1) + size = size_binop (MULT_EXPR, + fold_convert (sizetype, size), + fold_convert (sizetype, element_size)); + else + size = fold_convert (sizetype, size); + + if (!todo) + todo = TODO_update_ssa_only_virtuals; + + return size; +} /* Compute __builtin_object_size for CALL, which is a GIMPLE_CALL. Handles calls to functions declared with attribute alloc_size. @@ -1350,8 +1405,12 @@ call_object_size (struct object_size_info *osi, tree ptr, gcall *call) bool is_strdup = gimple_call_builtin_p (call, BUILT_IN_STRDUP); bool is_strndup = gimple_call_builtin_p (call, BUILT_IN_STRNDUP); + bool is_access_with_size + = gimple_call_internal_p (call, IFN_ACCESS_WITH_SIZE); if (is_strdup || is_strndup) bytes = strdup_object_size (call, object_size_type, is_strndup); + else if (is_access_with_size) + bytes = access_with_size_object_size (call, object_size_type); else bytes = alloc_object_size (call, object_size_type);