Message ID | DS7PR21MB34793E5E1EA2C050CB45B2A691719@DS7PR21MB3479.namprd21.prod.outlook.com |
---|---|
State | Committed |
Commit | 3d9853eeb2de07d26511c2335a29db8eeadb4d98 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 366CB3857706 for <patchwork@sourceware.org>; Mon, 8 May 2023 22:27:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 366CB3857706 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683584851; bh=4wY7Mid4bMP9edqC4tsh53YLlhxbljB2qCbbx+K1Ws4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xk675Fauz2GiOgYXAoeorZcVF/ERGajdT89CrWN+9C/vHj7YFbIMcxK0n6LkNHkG3 3cYeQywjuew9bUsWkSxeM9ekETEsp9uxR077dlXKoLhRg7sfmVDWcOutILV2zyBNkU XtdESDmxOqS4m+/5nWXsww+aqLfpiIWO6qUgBDk8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from BN6PR00CU002.outbound.protection.outlook.com (mail-eastus2azon11021018.outbound.protection.outlook.com [52.101.57.18]) by sourceware.org (Postfix) with ESMTPS id 4AA9D3857706 for <gcc-patches@gcc.gnu.org>; Mon, 8 May 2023 22:27:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AA9D3857706 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SFN8RkxS0stSqPOFnWUHVAa9yPnDfRvKJzOz2CXRRSqojY0CXzT1KXvQvlwSa6hseLdE742O45+D/jX04UT+S2mwoHjEs1xrN3N5TwQ2dBek5klUvmFAepbPgW8K08hPSXLOzVyV7y0ijid9TX9Bn/krpxGGhjYADllB1nlovhskKuZj010Ns52XgVFgFntyNTK+dqFkvodpJGtfroPAZ/dKOyQkgG1tL0Uof2DILp1Kn07JW57HivWpWjINHPBwomI7Lf7M8UICKHttubNhT1xUCGVRcfFhoQ0IrWI55Gj7XfLWWSGn8C6Us0KDe6SgcnoIvivDLtBCU6Y8+zEGAA== 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=4wY7Mid4bMP9edqC4tsh53YLlhxbljB2qCbbx+K1Ws4=; b=DwhHtMdaKVU8L/njNxFwa3+h67vfgRnlXRksQibLh/U3WFQBLpinhZ1GDF2aYw2b3b/hYoveKbVyMBr4hlg6F/CcFpZ7jgXKLO8/pi4bF6tiuXqtobiBt1j4bmQ3CH9Bb8qxbphBjq2swHpmRvXBLP20ufMYyrHiPru0AkFBbxvUMAKl5wmuaalsYAxUNeT539zshN0UiEhMB5sjENyUxnbiduhDQ7oQc+c/wpka0FCyBP1gapClNndUCYH/AcmPD92s8R1MQCc7bV1BXMa9v8iXtpt5KU5Jyq+MEhS+MaWb5OajB9MtpTEOhFiPLHoKklvPf7c9zJ90FITjwpcqVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none Received: from DS7PR21MB3479.namprd21.prod.outlook.com (2603:10b6:8:90::11) by SN7PR21MB3825.namprd21.prod.outlook.com (2603:10b6:806:29a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.3; Mon, 8 May 2023 22:26:58 +0000 Received: from DS7PR21MB3479.namprd21.prod.outlook.com ([fe80::9011:4e4d:fb2a:afd7]) by DS7PR21MB3479.namprd21.prod.outlook.com ([fe80::9011:4e4d:fb2a:afd7%5]) with mapi id 15.20.6411.003; Mon, 8 May 2023 22:26:58 +0000 To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org> Subject: [PATCH][PUSHED] Fix cfg maintenance after inlining in AutoFDO Thread-Topic: [PATCH][PUSHED] Fix cfg maintenance after inlining in AutoFDO Thread-Index: AdmB/CZPYX9P1GbjSH6tNwPKNHqyXg== Date: Mon, 8 May 2023 22:26:58 +0000 Message-ID: <DS7PR21MB34793E5E1EA2C050CB45B2A691719@DS7PR21MB3479.namprd21.prod.outlook.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=5835c0fa-87b4-4be5-b0b5-75c6f67925d4; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2023-05-08T22:24:00Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; x-bromium-msgid: d816bb44-61a8-471b-aeda-c16e2c5e1998 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR21MB3479:EE_|SN7PR21MB3825:EE_ x-ms-office365-filtering-correlation-id: 71aa03a5-233e-419b-1ddc-08db5013564b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7bZWK6E02usWmIet9dicmYl0rVKnbv2ue43S/SnvOZgGsYrhs3uAtUWG5nXR0odtEmpsvKvh48HCanCbD21PrwkZrOWzXRaPGZVchGXtqD3siRRZ3Owiv4RPmEtFAKlG61giZQp/TFN/PsNZak59NgCr5EI4uUVq5kW8CvWfahSqJ+igcNe1JzUv0awnciVp+MJjAZFNscTHUEzsAg62FbfVZqN09cBhW0ND/s+/FPAFuZtiukSy7QYFNvOV5KfAdBt6YJab7B9TlBLAG+FA9zvcWSpc3MWtWUO2J8R7kJlkREgBPS6/9ROrCnMYoS4Y5aF6XhiJ4EWZrO0XZcdD3ssJqlTnfTaFPbDGRNoN2aMsDSz8XaqMy6o0WvFbOMn3qYtUtKSaRLftF5E0yUg/WYrjTYxWpaZUauL8ksaniUQ1RCjFrWSUeiMiYl03AaejwPCGZbgodUm8jLjeZNedvrh3UgKVxu+UqERqj9MMfuHd01bw3EvoRx720aYjzQ766eWjxQgfxUQRHVcLZRUWUJjqtMcQtF8iTq1cpBG8xi2D3eWoROWMmmz8QkM6MdRV/wTSmNGX9hBFQTLuYKTMZ4Q1XHQZhPvmauxccetq7/AfGCqn/NCYgqHhEIGBfhge21QLMVOWJUh18Th9x+M4ShJXhTxTUfWboBabQJGv0oE= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR21MB3479.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(136003)(366004)(396003)(376002)(346002)(39860400002)(451199021)(122000001)(38100700002)(9686003)(186003)(82950400001)(82960400001)(38070700005)(83380400001)(6506007)(71200400001)(2906002)(8990500004)(8936002)(52536014)(86362001)(478600001)(10290500003)(786003)(7696005)(55016003)(41300700001)(66946007)(5660300002)(76116006)(316002)(6916009)(8676002)(66446008)(64756008)(66556008)(66476007)(33656002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: vvH3U2g90utJzqBt46lVhoF/JczGEHpWchsLFSYUPnamV+XWYbIxfYpSJcqXsJ9ADfSpktgrKQcLCXBjrCJz19mUzCcDaxVipILJjmhLLLSHGCE/rwkG7dWaLF23Uxrh81Woj1P1Dt7R8k7PLqQdi4hrj2Xb3C+bo8xmUw8N7Y83pljQ+kUxLSyfBSfIae0gmT3uESZ5oirpMoNwf0bLsCgBbi7gevVk/KpLBQbtVV3PBT4/l0eqV7XRhBBEsO298s1UCjEQOThxU4MYKWDlC08GPdM0HhI7w01UdnfGSWLitvw76SdKsWq4IFGteR/4056pzCl2Q3KkuSF9SCqD1QPFJ7eIIqCitEz7xjHUj32j7zl1uP1Abm7FCmQ05HgVy6QRpSCZYspxYNSoAZO3AX2oOcBpFOJyPDPweLiGbS152HLfkRFwa6ama66PbaOnP8Ggo2rK4pcZsAUydMW3gz1CWQAmLAaW3tTDIwnToceSUawdbAXWPHuixM9vBnocmw7sbJW7BQMm4rpfKZ2J83MF52DCfyMgso2J/Jjh8MoNQLERUV6mR6CpXYOPZ2M6V1j80giCd8/jkL7Oj+NqkRdVLPcNVVgwOTSkwotMxsvydUpLPhIOxaYo6rtm8vcyLnbnxWvuxY22vZd0G+LuE5/VFb9EJlp2xY9pv5ITMC2fSxFjQS4AIyCsW9r5KqubfLdDjT/0TKySCnM0aX1noAElN4lQqLC5xQtChmm2cPxDVChjlwh1eY6Nx84k5rqOmfS/VgPMfYRj6YOrRAuebRxVRuPIhxB6rKsQVKVaaVLVe1FRRisbDqlV8llBQumM2ziYwaVsYOEOY4oaXoQUW/nx8y03KKmqo9gMOAbmLIQ3qf9G4Udf7i248yWt4DsNAPFsC5MOVky+PQNHJAZSAlMGVaqFf7xq6m3TqVtgR4MICPfM43M0IfIkwyjcj67mHgU31ngCw6LQ1xo3fUQVXnZp4sfYxNM+ljA7oIksXEuV2Q2mge9+SyKq2HOtyhSGOg+YqOUcxOOFe6+9EToHB8KmMojJQjBbzLjXX9ZP7N8V9z5WUeYkGJHO9Sfnem6cMKG+sJQ9xU8eSw1vQily3JmnXTeBgceBhLPIgl6ivK2BGAyZVZyUpOBBBiOAMo9aiqaluAgcrKQry7CR39AUjc5geniRGUm3v8h3J5u37CeuIlWmXGyh0r1UQFF8AM+izygOsaFlIM6Blchdkh2efWSQiut3asHx0TWPMhtSiWe8ugF/fO2owkcp4yS9PXURj2vzTdNlHABApnmL5IIyFMwhQRDjavxNbhQlxTSbTjOm2B+DELt9RHSpit8D/t0YVCfhDjAI//bdozGwLs6sBnAd4udizii5iKT03MFxfxKc0lrmYvjyUrpC4HX/fn7m5ZdkZFIMTKllIJYpj74iHDepxeDotIw66JFybwYXWetsMMvwWZCSYa+/HdODBKnTYyi1U8eieu2+bhPYwq81DtsGYOmw1c3WtoR7gXzJrZhMPiFLi32Gc06Fam/xol75F2VN6bxLMeuR8hLO6Vo8yfMhZwsPM20ncQBPG4vvsfsmzHQEQiIeFJ5uL7CG8mZo2G1CJW6F/YFAQ5qyfy8bJyMPEe0vSv6gLyDXdQ4IzC3QVAGWzetmGKSiKk5KcRjA Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR21MB3479.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71aa03a5-233e-419b-1ddc-08db5013564b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2023 22:26:58.5275 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 1kcOyNkZEjBni0AFKhsXjiz2OM/d1zfIHbxpsi1bJQbRJfTeieyZmtmytgSNIZAbUGqujNfpLTOeGsi5YVpIBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR21MB3825 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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.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: Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[PUSHED] Fix cfg maintenance after inlining in AutoFDO
|
|
Commit Message
Eugene Rozenfeld
May 8, 2023, 10:26 p.m. UTC
Todo from early_inliner needs to be propagated so that cleanup_tree_cfg () is called if necessary. This bug was causing an assert in get_loop_body during ipa-sra in autoprofiledbootstrap build since loops weren't fixed up and one of the loops had num_nodes set to 0. Tested on x86_64-pc-linux-gnu. gcc/ChangeLog: * auto-profile.cc (auto_profile): Check todo from early_inline to see if cleanup_tree_vfg needs to be called. (early_inline): Return todo from early_inliner. --- gcc/auto-profile.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
Comments
On Tue, May 9, 2023 at 12:27 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Todo from early_inliner needs to be propagated so that > cleanup_tree_cfg () is called if necessary. > > This bug was causing an assert in get_loop_body during > ipa-sra in autoprofiledbootstrap build since loops weren't > fixed up and one of the loops had num_nodes set to 0. > > Tested on x86_64-pc-linux-gnu. > > gcc/ChangeLog: > > * auto-profile.cc (auto_profile): Check todo from early_inline > to see if cleanup_tree_vfg needs to be called. _cfg > (early_inline): Return todo from early_inliner. > --- > gcc/auto-profile.cc | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc > index 360c42c4b89..e3af3555e75 100644 > --- a/gcc/auto-profile.cc > +++ b/gcc/auto-profile.cc > @@ -1589,13 +1589,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts) > > /* Wrapper function to invoke early inliner. */ > > -static void > +static unsigned int > early_inline () > { > compute_fn_summary (cgraph_node::get (current_function_decl), true); > - unsigned todo = early_inliner (cfun); > + unsigned int todo = early_inliner (cfun); > if (todo & TODO_update_ssa_any) > update_ssa (TODO_update_ssa); > + return todo; > } > > /* Use AutoFDO profile to annoate the control flow graph. > @@ -1651,20 +1652,22 @@ auto_profile (void) > function before annotation, so the profile inside bar@loc_foo2 > will be useful. */ > autofdo::stmt_set promoted_stmts; > + unsigned int todo = 0; > for (int i = 0; i < 10; i++) > { > - if (!flag_value_profile_transformations > - || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) > - break; > - early_inline (); > + if (!flag_value_profile_transformations > + || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) > + break; > + todo |= early_inline (); > } > > - early_inline (); > + todo |= early_inline (); > autofdo::afdo_annotate_cfg (promoted_stmts); > compute_function_frequency (); > > /* Local pure-const may imply need to fixup the cfg. */ > - if (execute_fixup_cfg () & TODO_cleanup_cfg) > + todo |= execute_fixup_cfg (); > + if (todo & TODO_cleanup_cfg) > cleanup_tree_cfg (); > > free_dominance_info (CDI_DOMINATORS); > @@ -1674,7 +1677,7 @@ auto_profile (void) > pop_cfun (); > } > > - return TODO_rebuild_cgraph_edges; > + return 0; This change isn't mentioned - was it accidential? Otherwise looks OK. Thanks, Richard. > } > } /* namespace autofdo. */ > > -- > 2.25.1 >
>> free_dominance_info (CDI_DOMINATORS); @@ -1674,7 +1677,7 @@ >> auto_profile (void) >> pop_cfun (); >> } >> >> - return TODO_rebuild_cgraph_edges; >> + return 0; >This change isn't mentioned - was it accidential? No, it wasn't accidental. There is no reason to return TODO_rebuild_cgraph_edges since we called cgraph_edge::rebuild_edges () after each early_inline (). Here is more context before that diff: todo |= early_inline (); autofdo::afdo_annotate_cfg (promoted_stmts); compute_function_frequency (); /* Local pure-const may imply need to fixup the cfg. */ todo |= execute_fixup_cfg (); if (todo & TODO_cleanup_cfg) cleanup_tree_cfg (); free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); cgraph_edge::rebuild_edges (); compute_fn_summary (cgraph_node::get (current_function_decl), true); pop_cfun (); } return 0; Thanks, Eugene -----Original Message----- From: Richard Biener <richard.guenther@gmail.com> Sent: Monday, May 8, 2023 11:40 PM To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> Cc: gcc-patches@gcc.gnu.org Subject: [EXTERNAL] Re: [PATCH][PUSHED] Fix cfg maintenance after inlining in AutoFDO On Tue, May 9, 2023 at 12:27 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Todo from early_inliner needs to be propagated so that > cleanup_tree_cfg () is called if necessary. > > This bug was causing an assert in get_loop_body during ipa-sra in > autoprofiledbootstrap build since loops weren't fixed up and one of > the loops had num_nodes set to 0. > > Tested on x86_64-pc-linux-gnu. > > gcc/ChangeLog: > > * auto-profile.cc (auto_profile): Check todo from early_inline > to see if cleanup_tree_vfg needs to be called. _cfg > (early_inline): Return todo from early_inliner. > --- > gcc/auto-profile.cc | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index > 360c42c4b89..e3af3555e75 100644 > --- a/gcc/auto-profile.cc > +++ b/gcc/auto-profile.cc > @@ -1589,13 +1589,14 @@ afdo_annotate_cfg (const stmt_set > &promoted_stmts) > > /* Wrapper function to invoke early inliner. */ > > -static void > +static unsigned int > early_inline () > { > compute_fn_summary (cgraph_node::get (current_function_decl), > true); > - unsigned todo = early_inliner (cfun); > + unsigned int todo = early_inliner (cfun); > if (todo & TODO_update_ssa_any) > update_ssa (TODO_update_ssa); > + return todo; > } > > /* Use AutoFDO profile to annoate the control flow graph. > @@ -1651,20 +1652,22 @@ auto_profile (void) > function before annotation, so the profile inside bar@loc_foo2 > will be useful. */ > autofdo::stmt_set promoted_stmts; > + unsigned int todo = 0; > for (int i = 0; i < 10; i++) > { > - if (!flag_value_profile_transformations > - || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) > - break; > - early_inline (); > + if (!flag_value_profile_transformations > + || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) > + break; > + todo |= early_inline (); > } > > - early_inline (); > + todo |= early_inline (); > autofdo::afdo_annotate_cfg (promoted_stmts); > compute_function_frequency (); > > /* Local pure-const may imply need to fixup the cfg. */ > - if (execute_fixup_cfg () & TODO_cleanup_cfg) > + todo |= execute_fixup_cfg (); > + if (todo & TODO_cleanup_cfg) > cleanup_tree_cfg (); > > free_dominance_info (CDI_DOMINATORS); @@ -1674,7 +1677,7 @@ > auto_profile (void) > pop_cfun (); > } > > - return TODO_rebuild_cgraph_edges; > + return 0; This change isn't mentioned - was it accidential? Otherwise looks OK. Thanks, Richard. > } > } /* namespace autofdo. */ > > -- > 2.25.1 >
On Wed, May 10, 2023 at 12:05 AM Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> wrote: > > >> free_dominance_info (CDI_DOMINATORS); @@ -1674,7 +1677,7 @@ > >> auto_profile (void) > >> pop_cfun (); > >> } > >> > >> - return TODO_rebuild_cgraph_edges; > >> + return 0; > > >This change isn't mentioned - was it accidential? > > No, it wasn't accidental. There is no reason to return TODO_rebuild_cgraph_edges since we called cgraph_edge::rebuild_edges () after each early_inline (). Ah, OK. Patch is still OK. Thanks, Richard. > Here is more context before that diff: > > todo |= early_inline (); > autofdo::afdo_annotate_cfg (promoted_stmts); > compute_function_frequency (); > > /* Local pure-const may imply need to fixup the cfg. */ > todo |= execute_fixup_cfg (); > if (todo & TODO_cleanup_cfg) > cleanup_tree_cfg (); > > free_dominance_info (CDI_DOMINATORS); > free_dominance_info (CDI_POST_DOMINATORS); > cgraph_edge::rebuild_edges (); > compute_fn_summary (cgraph_node::get (current_function_decl), true); > pop_cfun (); > } > > return 0; > > Thanks, > > Eugene > > -----Original Message----- > From: Richard Biener <richard.guenther@gmail.com> > Sent: Monday, May 8, 2023 11:40 PM > To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com> > Cc: gcc-patches@gcc.gnu.org > Subject: [EXTERNAL] Re: [PATCH][PUSHED] Fix cfg maintenance after inlining in AutoFDO > > On Tue, May 9, 2023 at 12:27 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > > > Todo from early_inliner needs to be propagated so that > > cleanup_tree_cfg () is called if necessary. > > > > This bug was causing an assert in get_loop_body during ipa-sra in > > autoprofiledbootstrap build since loops weren't fixed up and one of > > the loops had num_nodes set to 0. > > > > Tested on x86_64-pc-linux-gnu. > > > > gcc/ChangeLog: > > > > * auto-profile.cc (auto_profile): Check todo from early_inline > > to see if cleanup_tree_vfg needs to be called. > > _cfg > > > (early_inline): Return todo from early_inliner. > > --- > > gcc/auto-profile.cc | 21 ++++++++++++--------- > > 1 file changed, 12 insertions(+), 9 deletions(-) > > > > diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index > > 360c42c4b89..e3af3555e75 100644 > > --- a/gcc/auto-profile.cc > > +++ b/gcc/auto-profile.cc > > @@ -1589,13 +1589,14 @@ afdo_annotate_cfg (const stmt_set > > &promoted_stmts) > > > > /* Wrapper function to invoke early inliner. */ > > > > -static void > > +static unsigned int > > early_inline () > > { > > compute_fn_summary (cgraph_node::get (current_function_decl), > > true); > > - unsigned todo = early_inliner (cfun); > > + unsigned int todo = early_inliner (cfun); > > if (todo & TODO_update_ssa_any) > > update_ssa (TODO_update_ssa); > > + return todo; > > } > > > > /* Use AutoFDO profile to annoate the control flow graph. > > @@ -1651,20 +1652,22 @@ auto_profile (void) > > function before annotation, so the profile inside bar@loc_foo2 > > will be useful. */ > > autofdo::stmt_set promoted_stmts; > > + unsigned int todo = 0; > > for (int i = 0; i < 10; i++) > > { > > - if (!flag_value_profile_transformations > > - || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) > > - break; > > - early_inline (); > > + if (!flag_value_profile_transformations > > + || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) > > + break; > > + todo |= early_inline (); > > } > > > > - early_inline (); > > + todo |= early_inline (); > > autofdo::afdo_annotate_cfg (promoted_stmts); > > compute_function_frequency (); > > > > /* Local pure-const may imply need to fixup the cfg. */ > > - if (execute_fixup_cfg () & TODO_cleanup_cfg) > > + todo |= execute_fixup_cfg (); > > + if (todo & TODO_cleanup_cfg) > > cleanup_tree_cfg (); > > > > free_dominance_info (CDI_DOMINATORS); @@ -1674,7 +1677,7 @@ > > auto_profile (void) > > pop_cfun (); > > } > > > > - return TODO_rebuild_cgraph_edges; > > + return 0; > > This change isn't mentioned - was it accidential? > > Otherwise looks OK. > > Thanks, > Richard. > > > } > > } /* namespace autofdo. */ > > > > -- > > 2.25.1 > >
diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index 360c42c4b89..e3af3555e75 100644 --- a/gcc/auto-profile.cc +++ b/gcc/auto-profile.cc @@ -1589,13 +1589,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts) /* Wrapper function to invoke early inliner. */ -static void +static unsigned int early_inline () { compute_fn_summary (cgraph_node::get (current_function_decl), true); - unsigned todo = early_inliner (cfun); + unsigned int todo = early_inliner (cfun); if (todo & TODO_update_ssa_any) update_ssa (TODO_update_ssa); + return todo; } /* Use AutoFDO profile to annoate the control flow graph. @@ -1651,20 +1652,22 @@ auto_profile (void) function before annotation, so the profile inside bar@loc_foo2 will be useful. */ autofdo::stmt_set promoted_stmts; + unsigned int todo = 0; for (int i = 0; i < 10; i++) { - if (!flag_value_profile_transformations - || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) - break; - early_inline (); + if (!flag_value_profile_transformations + || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts)) + break; + todo |= early_inline (); } - early_inline (); + todo |= early_inline (); autofdo::afdo_annotate_cfg (promoted_stmts); compute_function_frequency (); /* Local pure-const may imply need to fixup the cfg. */ - if (execute_fixup_cfg () & TODO_cleanup_cfg) + todo |= execute_fixup_cfg (); + if (todo & TODO_cleanup_cfg) cleanup_tree_cfg (); free_dominance_info (CDI_DOMINATORS); @@ -1674,7 +1677,7 @@ auto_profile (void) pop_cfun (); } - return TODO_rebuild_cgraph_edges; + return 0; } } /* namespace autofdo. */