From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id AB1ED385842E for ; Mon, 1 Aug 2022 18:53:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB1ED385842E Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 271Hs4Mn010152 for ; Mon, 1 Aug 2022 18:53:05 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hmue2mmwn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Aug 2022 18:53:05 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 271HIYGx004141 for ; Mon, 1 Aug 2022 18:53:04 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hmu31jwt3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Aug 2022 18:53:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lWpkUI/m7mn45oxIdvp9nLTRUbrxuXLFN9IjFvXx0MyoeX4Uh0zlGyCkfpd/H5OsI0KkBohQMFpYU0xItMxt6u3XYsyaS4DM0hcA/he05hll/KSxy6iQysUB/4oHL9+fX7ySy7tCYBowFZt8M/JNXVX0xvGFvFO2FQ9xXfNKfxNE0VHHj7xYdXI2TFqvSQlkhmDPW9LpX8gQrXnUT0wa/5ImHBDPS5suqI5H3APOtu217UBgkSGY3Eqxw0eJeWZU/9C8o4m98zkqsDPm1dO1vVvEPnNvyusgHZ/OoOfI/MynDpv6/qjDxA0+KAcbC7qhahytrQDs3BeFYPWj2qxEgg== 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=g8g9x4PatQ+q2ATtAl3MBJMxQj8p2r5fLn7v+CM4xW8=; b=jtc2fe1JK0l1/LS7N+qBDdnaih2EQ1y99B4GPmZa8uK48XAvr+0q8CgJx62uKlAXWJGxtRfptcHKhX5r/0/BY7U9BR1PtxR/Z0eMF5wLXkFS49rWK/X6g7CGNvz2J+cb+qjlOI4EVsdTgvww8Ck+s5K2dnG06w+fI2nu//vVuiHozEpfQEXvPhlQ9J+mHLv25N3TXSsyuW8JCivEc3eJfLoTw3xdnP8yygZ4eJPuOfT/Wr24UqA/EOplbS1bHwnWhjcbb2+RbWmLhP+tyNVqGYLSzNCxaqa2pA/5NSh+D59REx49gjJ/+iVEm0vdkTX2joqMexu1shpEkdN6OSiu3Q== 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 Received: from MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) by BN8PR10MB3506.namprd10.prod.outlook.com (2603:10b6:408:ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12; Mon, 1 Aug 2022 18:53:02 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::815f:640c:8792:186b]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::815f:640c:8792:186b%5]) with mapi id 15.20.5482.016; Mon, 1 Aug 2022 18:53:02 +0000 Message-ID: Date: Mon, 1 Aug 2022 11:52:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] btf: do not use the CHAR `encoding' bit for BTF Content-Language: en-US To: Indu Bhagat , "Jose E. Marchesi" References: <877d458k7r.fsf@oracle.com> <3c4bc777-c472-d5a1-74f2-1a99b951e9db@oracle.com> Cc: gcc-patches@gcc.gnu.org From: David Faust In-Reply-To: <3c4bc777-c472-d5a1-74f2-1a99b951e9db@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BYAPR11CA0055.namprd11.prod.outlook.com (2603:10b6:a03:80::32) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f33defc-8ebe-4f7f-c2e0-08da73ef0f83 X-MS-TrafficTypeDiagnostic: BN8PR10MB3506:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +N1qx17uk9zXObAOBEnf7liAkcYH1yLjddDnghDwLLRGCMQ57nZrBjA3T5PkzENoXx3No5CAqTNRYz4mxX8IgDs8JlkRqHio7GvwlAF2XGvgfFkfrv8HliWu5Qxnza+0CUlvx3M2T/R10eY2UvBojcfzbWJliie0ebfHZ10+g5nwpRtvMEFZaT9OJWgiHtNqVURPItovtVTX+W5f32S0dJQgOfj5ZFqxspVQPV52kl0yRxQGkKask5e51X27nlr63SuSbDrPymq3maksoivCbsDRY5sq+es9OwcQLyrbfPRWteod6nfe1uvrYEPxMx3nZtSIgjVNXWomiLagBzxAJM8+tjgeD2u+DdHU24sMj2cK2Mk3cmVK9uO/oConu7JlUhtT6kvkHv0fqLcleyDV3WA6wTRSzSc6QZYv5ng+g/3QecJ6P95vf1MI86hRVbqAAfGpGSWUJ7C54+LjUUuT7zINjQfmhuxnR9wTg3/FJ/ZTH+Plnpsyx35BmFzK4Ax3/VktlrPMwy3VANtFihNGxEvjpor8VWHsk6FqZLgSCCo3rRVH01FcWZt3kBMaczpxNKYSNLbd3rbexTLT41zfAYbcctyavf16dQRBMXrEb/q8Y8P0MrJkGg3lRsBoddP/OP3mpmVP5zJmY/JaUVM5P8wY/AB/OCTN0cehedLtc5Sph6naVZeLotlSf/hW8APIguY7outuac0AX2HNydDUr0OU1071ZS1zga7+/50RE+ZC7HqamG0WolSvaDp9huAeNbrh7lH2bTv8QDilEz1qilFVMblFzq9vrpkPoCkdgp65piBqYjJzzGhwH9alEEFlET2M4fv6V8LRyzUkEnFjc5yQxct/Nu9ecYzhl99Nvfaq5AcopPxXdDC6+6XcN2ON X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR10MB3213.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(376002)(346002)(39860400002)(366004)(136003)(396003)(186003)(6506007)(53546011)(84970400001)(2906002)(6666004)(6512007)(2616005)(38100700002)(86362001)(31696002)(83380400001)(41300700001)(8936002)(4326008)(8676002)(66476007)(66946007)(66556008)(44832011)(31686004)(5660300002)(36756003)(6486002)(478600001)(966005)(110136005)(6636002)(316002)(81973001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K2ZnMjZNYy9KWlBpY0EyelYvbnRQeThzUGxrbWkyd1ZaR0VsVkEvVC81T0Vx?= =?utf-8?B?VElaUkRVcTBSUG9wVGpVMGlwcFRJUGxwRElzcERNNVRmWXJVQUNZcjBWeEFk?= =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XozZXRtVlc1THNtM3VK?= =?utf-8?B?RzU0QWNVVUQ4RUphTDRjMUFMbnBXcTNrRTlMN2Vhb1R3SUJsdnNEMzF4bzE3?= =?utf-8?B?c3lUMVlLYVRNakxtQURabCtPVkY1ZjJGUW4xM2dGOXdSeUZDN2FKcDZUbis5?= =?utf-8?B?WTVtQTZ5QUNhYk40YWFjaHVWdEhhdCt2ak53SjQ4SGlyMlZqYmFPMWt0aDZU?= =?utf-8?B?Zm9mWWNLU1loWGJFU3NiWE8rcjhlZFF4ZGJCVTdKSjBEN01CUkQvWUhWdXk2?= =?utf-8?Q?z43xl4zxxID7DOGzj8ZBUyE=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f33defc-8ebe-4f7f-c2e0-08da73ef0f83 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 18:53:02.3205 (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: 568HDCL7cWkGXomWEpkI2F8g86+QlH0So7T7rnyJQMvGM2nV8cwdVDNy9BD3FMRUdIan7mVKsZnLRaKO3u715A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR10MB3506 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-01_08,2022-08-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208010094 X-Proofpoint-ORIG-GUID: ioEPDPex0yQgv_gCI4r4aRrQLqbrRd4C X-Proofpoint-GUID: ioEPDPex0yQgv_gCI4r4aRrQLqbrRd4C X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 18:53:07 -0000 On 7/26/22 14:58, Indu Bhagat wrote: > On 7/22/22 4:23 AM, Jose E. Marchesi via Gcc-patches wrote: >> >> Contrary to CTF and our previous expectations, as per [1], turns out >> that in BTF: >> >> 1) The `encoding' field in integer types shall not be treated as a >> bitmap, but as an enumerated, i.e. these bits are exclusive to each >> other. >> >> 2) The CHAR bit in `encoding' shall _not_ be set when emitting types >> for char nor `unsigned char'. >> > > Hmm...well. At this time, I suggest we make a note of this in the btf.h > for posterity that BTF_INT_CHAR is to not be used (i.e., BTF_INT_CHAR > should not be set for char / unsigned char). Agreed it would be good to add this note. > >> Consequently this patch clears the CHAR bit before emitting the >> variable part of BTF integral types. It also updates the testsuite >> accordingly, expanding it to check for BOOL bits. >> >> [1] https://lore.kernel.org/bpf/a73586ad-f2dc-0401-1eba-2004357b7edf@fb.com/T/#t >> >> gcc/ChangeLog: >> >> * btfout.cc (output_asm_btf_vlen_bytes): Do not use the CHAR >> encoding bit in BTF. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.dg/debug/btf/btf-int-1.c: Do not check for char bits in >> bti_encoding and check for bool bits. >> --- >> gcc/btfout.cc | 4 ++++ >> gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c | 18 +++++++++++------- >> 2 files changed, 15 insertions(+), 7 deletions(-) >> >> diff --git a/gcc/btfout.cc b/gcc/btfout.cc >> index 31af50521da..576f73d47cf 100644 >> --- a/gcc/btfout.cc >> +++ b/gcc/btfout.cc >> @@ -914,6 +914,10 @@ output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd) >> if (dtd->dtd_data.ctti_size < 1) >> break; >> >> + /* In BTF the CHAR `encoding' seems to not be used, so clear it >> + here. */ >> + dtd->dtd_u.dtu_enc.cte_format &= ~BTF_INT_CHAR; >> + > > [Added David Faust] > > What do you think about doing this in btf_dtd_emit_preprocess_cb () for > types where kind == BTF_KIND_INT. This is the place where BTF specific > massaging of type info takes place. Sorry for the delay. I think this could be done in either place. I lean slightly in favor of doing it here as implemented in this patch. Other integer encodings are not specifically massaged into BTF; we leave the in-memory representation the same as CTF and just write them out according to the BTF rules since both formats hold the same information, and this function is where we do that. In my opinion, this is a similar case. It is not wrong hold on to the information (internally) that this is a char type, rather it is a quirk of the other BTF encoding rules which means it _is_ wrong to ever set the bit saying as much when writing the BTF info (at least for now...). So, this patch LGTM, but please add a brief note in btf.h that the CHAR flag is currently not to be used. Thanks > >> encoding = BTF_INT_DATA (dtd->dtd_u.dtu_enc.cte_format, >> dtd->dtd_u.dtu_enc.cte_offset, >> dtd->dtd_u.dtu_enc.cte_bits); >> diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c >> index 2381decd6ff..87d9758e9cb 100644 >> --- a/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c >> +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c >> @@ -4,7 +4,8 @@ >> | 0 | encoding | offset | 00 | bits | >> encoding: >> signed 1 << 24 >> - char 2 << 24 >> + char 2 << 24 (not used) >> + bool 4 << 24 >> >> All offsets in this test should be 0. >> This test does _not_ check number of bits, as it may vary between targets. >> @@ -13,13 +14,14 @@ >> /* { dg-do compile } */ >> /* { dg-options "-O0 -gbtf -dA" } */ >> >> -/* Check for 8 BTF_KIND_INT types. */ >> -/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 8 } } */ >> +/* Check for 9 BTF_KIND_INT types. */ >> +/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 9 } } */ >> >> -/* Check the signed/char flags, but not bit size. */ >> -/* { dg-final { scan-assembler-times "\[\t \]0x10000..\[\t \]+\[^\n\]*bti_encoding" 3 } } */ >> -/* { dg-final { scan-assembler-times "\[\t \]0x20000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */ >> -/* { dg-final { scan-assembler-times "\[\t \]0x30000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */ >> +/* Check the signed flags, but not bit size. */ >> +/* { dg-final { scan-assembler-times "\[\t \]0x10000..\[\t \]+\[^\n\]*bti_encoding" 4 } } */ >> +/* { dg-final { scan-assembler-times "\[\t \]0x..\[\t \]+\[^\n\]*bti_encoding" 3 } } */ >> +/* { dg-final { scan-assembler-times "\[\t \]0x.\[\t \]+\[^\n\]*bti_encoding" 1 } } */ >> +/* { dg-final { scan-assembler-times "\[\t \]0x40000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */ >> >> /* Check that there is a string entry for each type name. */ >> /* { dg-final { scan-assembler-times "ascii \"unsigned char.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */ >> @@ -42,3 +44,5 @@ signed int f = -66; >> >> unsigned long int g = 77; >> signed long int h = 88; >> + >> +_Bool x = 1; >> >