[GCC13,V2,0/2] Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836
Message ID | EC1BCFDF-E10C-45EA-9CEA-B5C4291CDA49@oracle.com |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2472468eik; Tue, 19 Jul 2022 07:08:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uhyQhJVcmGyK3ypUoNGqCnu9B2dVsMN3oHzh/j4CufSVgXBVx3kTJOGTC8p1OfLwRTMW4Q X-Received: by 2002:a17:907:2ceb:b0:72e:dd6c:1b96 with SMTP id hz11-20020a1709072ceb00b0072edd6c1b96mr24780463ejc.503.1658239717324; Tue, 19 Jul 2022 07:08:37 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j19-20020a05640211d300b00435799ce323si23680006edw.190.2022.07.19.07.08.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 07:08:37 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=kBiLjCoA; arc=fail (signature failed); 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DBEA385783E for <ouuuleilei@gmail.com>; Tue, 19 Jul 2022 14:08:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DBEA385783E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658239716; bh=0A4kcVXm19d05fI+nLpXVLmrxq5xG0aemEOCiirX2rU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=kBiLjCoAbybySbM+33gPZobtXbD8QKoFuxLnEvKJgoh6uFXevjqcVXaFl4OMPMMpj cnEM7Jkpo/XWPVkIKxHwxfUe6Gv7t405z2/bCKeSnIO2M320Hw9vztV/iWQctJMOY4 oEELqRB0LCIdGdsSDm1/9fBCTHnWKgV4APW3b8UI= 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 B3B6D3858439 for <gcc-patches@gcc.gnu.org>; Tue, 19 Jul 2022 14:07:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3B6D3858439 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26JDBFrx017922; Tue, 19 Jul 2022 14:07:47 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hbkx0xj91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jul 2022 14:07:47 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 26JBsCPg039256; Tue, 19 Jul 2022 14:07:47 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hc1k4s4u0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jul 2022 14:07:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DNQykOHRPIlfaliLOfXh+MY5Aivhs6MtpR+i27/j7fZXnOCJ/pdcNTbHBgQoeA0GDFOMETezK/kf78Sqkk0ErmEMF2XPONDwog8AdgbREk+eFZV7Lh+tZuNNQPps+Ckzpk7bOvzMkqSw5XxX4ZwXtmN1RHD+/g7sd4qzDAH7nlpvCY1S9eTaCNfd7Tz9aMBmtf5JwfQX6EqvDvZ+fyupUs+4vXrFMBoXb12+wuyuliJkC15IsqJ1T6SViEXIJxcqByUJTbHXBLHr24e3sq27R8ugLb6HgpA8eBWKgtS414g+3IQ5FaYiyOBged02yAsKAkgbvgqG/JU3dXN798aOqg== 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=0A4kcVXm19d05fI+nLpXVLmrxq5xG0aemEOCiirX2rU=; b=ekX4W5GfGDw/a4kKhYtZxCD2ozTzMtaQr4U4n3Kwa88euDzubST3Bk9/Fhhv6zykMJVoaSPEEWgRKYWg3Q62C73dAC7tuMWxhsEHNBKtDL8079ZyJRFZoebFsWTUP1O9UyQtZ1Q9eB+vhxVzCvHJytJpRJ+naRsVwAUBLqMnfR05QWwMIVPifljJmT3vVtpZune6Y0YWgL9R0/RN5XLdKNqqOJB5UXrjN+IHXw2mgtELTvTaZSvwDwuR3dC6Vas643bfWEcdfBVj5OxAOJFmjn1oCFHYeX1brRy24ZopDa0st47An58Bj7csY8wN7UffZAr6eJ0bG2kdKQNGcYJaYg== 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 CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by SA1PR10MB6320.namprd10.prod.outlook.com (2603:10b6:806:253::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Tue, 19 Jul 2022 14:07:44 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::2d14:50e4:3bb:4e30]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::2d14:50e4:3bb:4e30%9]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 14:07:44 +0000 To: gcc-patches Paul A Clarke via <gcc-patches@gcc.gnu.org> Subject: [GCC13][Patch][V2][0/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836 Thread-Topic: [GCC13][Patch][V2][0/2]Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836 Thread-Index: AQHYm3jqtuYAQmTzT0C8LQzub+3ONw== Date: Tue, 19 Jul 2022 14:07:44 +0000 Message-ID: <EC1BCFDF-E10C-45EA-9CEA-B5C4291CDA49@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3608.120.23.2.7) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8240a210-1e76-41a5-3c41-08da69900d7b x-ms-traffictypediagnostic: SA1PR10MB6320:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WWbLdh/JIYxA79q1xogmtAkq7uIX3++qs680xljLkLhD9GIc9NJ9L7JAg9wb45zTNHtO6vgGS4e+6CiPMn8njuQKqnbkVn5DlzuBr0lUYwAgJfuEFksAte+cGG1Y8FF8b84MH69jRq3oA0W3nZ+abFF79fNevy3bBha4WpaQUsKXKN5sW3u9Sh3SeUc585q2yiXRQHMHmQ3xwOYQmQlwDecXd8cyajDXzJqYKh1jw7zeSs33UyUSbz0MgNEjppi1FJJjDFZjRWkociGKmnqUzvBqvGwcQquSy/N3r8MXOEN3ZNKAmg+JJOQxg39MkzA1RPWy2wD2nOZrxbGwWwhA0p7ugw2mz4n7bZiMoI4Sv+Rgcw4pFb9pa48S42NNkeq+EMAuobbhs/VBLLg0yeuuN+XTqwuosz619Qa+1ZNM7nQwGZ6v7sZFvY5K2ORcagvejYDOLnsA/hZ6ReMdA2s2DpGhoCGKDT+/hxwCVeGNF+ArPQ0djZCS+TIh2k9gAc62JXPmD2Ht343IX81XTVN3RUCUfaXt1VLtmhAFCSy0i2UEcBgAPa4j1D8aLdt7XQVwcKAvMS3mtD3PHvVukKuZRF9ImMwpe7NI2iv+gMq2xFxvvkVxwSpSUkJGK3kWf/nZ6Z0v2ko5gt1z0gB1ERqNo7Yn38wc5tMA1UBMt2QECONRAEgA1kFb7xY5evZtWMCBsErwllwKisq+SN6eZR4Ee4DlC9k7Uxck2qg5SRQqTh9HQRSEPmC6XMNAAUZRdcZlAQ8mIkua/3vdwzdlzNNVvFAA3HZ7QqaWkuGZP1b+7SKoq8kUOOvxob2uWmb94HWs94knu7qe118vOk66VLbhsysfV8PK+YIxPHxkeWFOF+v7O5NjM9UknIebr1oZwdlu4W6iLna72Mltc0lWtdYnWQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4344.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(39860400002)(396003)(376002)(346002)(136003)(966005)(6486002)(71200400001)(86362001)(478600001)(38070700005)(186003)(6512007)(6506007)(91956017)(316002)(6916009)(54906003)(41300700001)(83380400001)(4326008)(8676002)(66446008)(76116006)(66556008)(64756008)(5660300002)(33656002)(8936002)(66476007)(44832011)(2616005)(2906002)(36756003)(38100700002)(66946007)(122000001)(45980500001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?4sOU1z3C34b2LkwyFT2UbvkYC7zp?= =?utf-8?q?06SXbGrwwob2oXU4VoXmF3MUOJV7Fa0otY5eJU6HrzSx2OdXm9UTzTLL5Te5Z/BxH?= =?utf-8?q?03XxYXiaoryFrXkDwgPLHb54a1Roq4dDL4EAmpKheBwZEyjMmai8zPf3yK2wgXr/j?= =?utf-8?q?cD1HEBTKm9W+yQzglJUNpTESfN7Vzxra8J1jhwq4FAoY/xlDeWcrH8n/JRUEB4GDJ?= =?utf-8?q?keIls3MiLKGjpgFOzXIDo5Zbvv3KpQwEMXlugtQ+g86NPkxsvQ0/IwzQi3RUAOSYr?= =?utf-8?q?pECTlOMFaeKNqY/pkH54fqOm/0ACkFZ9alTHmdP+eQ+Cb1SKguPF+Dc0+TZcTyLtP?= =?utf-8?q?eYMgKMwz8FGZDNAtBfyBQePVdopAORdsk4LytTRDCYJu1kad63L+AAUx1OUmXPSLK?= =?utf-8?q?LaKzoPy0JmiNHV2fXg7jisXq1RuzaSD6A2262CsMu2508G7gZexoMo+e0u9moJGjG?= =?utf-8?q?h+x1VeYyLYz9NsgpM8aQHlKkdDs75xR8QnG4m78zlJvwICtktGFye69v90r9XXKrH?= =?utf-8?q?An1Ueulps3X2960ciOWp0cTzULOaIuy2vqnJPuzvvDesV47KBqelTXmSdQrmc1fqH?= =?utf-8?q?dVqvzAePNVi/fBqjVAGps0JNwbxjvyxWQ9xoQItAkPVpAaLEqtSQ994y6z2YVV0ke?= =?utf-8?q?vF3jaR+M/oAKxjBA40dSja8jBJvmejltVQ3d5+RFgxBAjQfP8ml5XI2FIWeqjdJx8?= =?ut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3D?= Content-Type: text/plain; charset="utf-8" Content-ID: <F3D57CAD69790343932F9ED7CEDFC17F@namprd10.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8240a210-1e76-41a5-3c41-08da69900d7b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2022 14:07:44.8577 (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: XO7CiejKV9CP31oj+3RPejwY8+HJ3cHjGwSYTMcWUjDWr2qTve8RFlwUdDrRF1HaMtRip2w60YGgEZ5fAsOQfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6320 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-07-19_02,2022-07-19_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207190059 X-Proofpoint-GUID: MYEUNwQ-7AgSawLcZ3iNVpyrL1kAgvKo X-Proofpoint-ORIG-GUID: MYEUNwQ-7AgSawLcZ3iNVpyrL1kAgvKo X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, KAM_SHORT, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Qing Zhao <qing.zhao@oracle.com> Cc: jakub Jelinek <jakub@redhat.com>, Richard Biener <rguenther@suse.de>, martin Sebor <msebor@gmail.com>, "Joseph@codesourcery.com" <Joseph@codesourcery.com>, Kees Cook <keescook@chromium.org> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1738790369445563806?= X-GMAIL-MSGID: =?utf-8?q?1738790369445563806?= |
Series |
Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836
|
|
Message
Li, Pan2 via Gcc-patches
July 19, 2022, 2:07 p.m. UTC
Hi, Based on the previous discussion on the Version 1 of the patch: https://gcc.gnu.org/pipermail/gcc-patches/2022-June/597350.html https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598010.html We decided: *****User interface: . command line option in C/C++: -fstrict-flex-array[=N] (N=0, 1, 2, 3) . decl attribute for FIELD_DECL: strict_flex_array (N) (N=0, 1, 2, 3) *****Implementation: 1. Add a new IR flag “DECL_NOT_FLEXARRAY” to FIELD_DECL; 2. In C/C++ FE, set the new flag “DECL_NOT_FLEXARRAY” for a FIELD_DECL based on [0], [1], [] and the option -fstrict-flex-array, the attribute strict_flex_array and whether it’s the last field of the DECL_CONTEXT. 3. In Middle end, update any place that treats trailing array as flexible array member with the new flag DECL_NOT_FLEXARRAY + array_at_struct_end_p to control the behavior with Multiple level consistently. Then the above implementation will be divided into the following 3 parts: Part A: 1 + 2 Part B: In Middle end, use the new flag in tree-object-size.cc to resolve PR101836, then kernel can use __FORTIFY_SOURCE correctly after this; Part C: in Middle end, use the new flag in all other places that use “array_at_struct_end_p” or “component_ref_size” to make GCC consistently behave for trailing array. This set of patches (2 patches in total, the #1 is for Part A, and #2 is for Part B) are for the above Part A and Part B. NOTE: After this set of patches, the one major issue remained in GCC is, different phases that call either “array_at_struct_end_p” or “component_ref_size” behave inconsistently on the default behavior of what’s a flexible array member, some phases treat all trailing array as flexible array member by default, and some phases treat trailing [], [0], [1] as flexible array member by default. Such inconsistency need to be resolved in Part C. I have bootstrapped and regression tested on both aarch64 and x86, no issues. Let me know if you have any comments on the patches. Thanks. Qing