From patchwork Fri Oct 21 01:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 6471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp425922wrr; Thu, 20 Oct 2022 18:53:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fBoF/KXhM0DDtva4/qfFmhs5WuB93jxWFpvX6nFABAtv7qF5Q539IN+F4af9J6is/xA8E X-Received: by 2002:a17:907:97ca:b0:791:644c:491e with SMTP id js10-20020a17090797ca00b00791644c491emr13046432ejc.555.1666317180612; Thu, 20 Oct 2022 18:53:00 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b26-20020a1709062b5a00b0078cbe9d08c6si15043896ejg.197.2022.10.20.18.53.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 18:53:00 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=UVpNvygm; arc=fail (signature failed); 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50C2B3858297 for ; Fri, 21 Oct 2022 01:52:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50C2B3858297 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666317179; bh=NyDFWpF6VIyGIywJDm5ew1R+H79fVjJZYtCCFfFAB3g=; h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UVpNvygmEe/XD3eMDQr5xUnQ1+lJd4cBi0uZiNyDfkObI8qirhMJqGJalkl8Dx3iU w7lCw8+KZeCSPjCu5AB+W9RBigXLhL+8JFlURYdABcKWqN23E+RsNlTOAL7SSwA+oi YMn/aii8PqYXAsVwfCUVcnCx5VY8dqjbLt0UaMUw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id 373373858C33 for ; Fri, 21 Oct 2022 01:52:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 373373858C33 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="307984390" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="307984390" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 18:52:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="632623679" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="632623679" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga007.fm.intel.com with ESMTP; 20 Oct 2022 18:52:08 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 20 Oct 2022 18:52:08 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Thu, 20 Oct 2022 18:52:08 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Thu, 20 Oct 2022 18:52:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8OokPCZmQkFFaBK9j1gsSwQ0tuRExrv+pqwxytCAQDYuuV06kjcFiAi/5Hs3a+frPFlTmhZZW2J2C1PqUgPEjqfwwb6ulfnUVKLn14qPgDbUaPJV/LrhiVxGvfho0f/EpuQEXI0klQMSFz6L3spVA8vkDIeT413mIoMerN4CL6XMm3MN8JMshDL1rNYPieoQbVwPVxm/5s5SN28RBMP3yjM5ld9g0vJth12y+r244+IfgIBz1nrs8Ic+XcVl7sZL4leR3YC6Hk+STWpinaGq7u0Zq6TBgqUqZzDhjXxmZx5F0ESZ3hvimGkOPS53RBv5pCuGh6oLjHZ7X0bD/xfBA== 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=NyDFWpF6VIyGIywJDm5ew1R+H79fVjJZYtCCFfFAB3g=; b=dnoPagw3AmZIpXEv/RCS3s2m+5dRxNmSdLIjvlH1lbPSa9OjIGk6+dLWE9NsQy7gz2T26NNDuygSVKQy4bZI8A9lrPxH/YTbuaQA2/1ZVMrub1dOYLry19DBTwY0hMA1MtNKgoff57rG/fIZINWz9HiGpWpze6NRYhWOA2/IQy6JOfg79qaLeuHKoU3/phrtJ/fN97WIeaDiFPP+CEzk73l4p3FyU5t6CCUZFX6tlnMZ9AjlWGq6+HR/fBnPzJ9L/67viaZgdj349dhFWdKf3DF4KU8pA1OfPxmZJ/L9FV4BGI8WfmMvlxlpJ/FUV4HhR+QSAH4UluCBCP+hiQTiTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SJ0PR11MB5600.namprd11.prod.outlook.com (2603:10b6:a03:3ab::16) by SJ0PR11MB5086.namprd11.prod.outlook.com (2603:10b6:a03:2d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Fri, 21 Oct 2022 01:52:06 +0000 Received: from SJ0PR11MB5600.namprd11.prod.outlook.com ([fe80::ab0c:3707:53c9:656b]) by SJ0PR11MB5600.namprd11.prod.outlook.com ([fe80::ab0c:3707:53c9:656b%7]) with mapi id 15.20.5723.035; Fri, 21 Oct 2022 01:52:06 +0000 To: "Cui, Lili" , Jan Hubicka , "jh@suse.cz" Subject: Ping^3 [PATCH V2] Add attribute hot judgement for INLINE_HINT_known_hot hint. Thread-Topic: Ping^3 [PATCH V2] Add attribute hot judgement for INLINE_HINT_known_hot hint. Thread-Index: AQHY5O+5iNbZPGz9eUu3vBldSE0Oxg== Date: Fri, 21 Oct 2022 01:52:06 +0000 Message-ID: References: <20220920084810.25157-1-lili.cui@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR11MB5600:EE_|SJ0PR11MB5086:EE_ x-ms-office365-filtering-correlation-id: 286cda97-57cb-4090-d694-08dab306dba2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MFuZmM1+66U5gHU+cezomRhIhRSa2H6S7PqMeWNhKzcDIyUpvhKqrmHFpV7iDcsAAIkdGhKD/kCnbhbHxiCmrkRWVRqXQF2baudPdYFxpEpDToTYegjyjboHCOj/0bU32GWs8IH38FsAW+4Aq0dPu67r2Yena3SJ+KihDmlJ3SLVbiSYJWdFlHhAAl+zbJeU0qsh4d1+0ar/CbzMxnX4NSeJrm1+cdnlmisjUGsAd7S6gQmaZYZMmiHTWlXAroj49wQcCDbi11rELZSO8ax5GceubJ6TZFQ9MEUXGhwtXw4qpy/3+W/tuwNyAm8WVueZiWQgo+GTeySCRDqTBDwu9Z+Io0favXNBjWNjj2ndAExBu5PVWw0fUGR+qha73dYlLAKIebmBWUEM4wtduJLYJG81j/qij2/vMcPT1wkQxsfAQXpwhpZzhxwxt3q/kJrEjj6UP3578WoO+6cQjH2f2qF7SREltkJXrtS3/iHxqh0J4kJdi8fSkllR+U86325lZ4zm2rrXxpydwX/AQ0d8z50/8DvXpSXKp1oZZDaPeKOIkJY0cmLhq2qP89miZfGHZPgDa0WT8l6Pft7OK53P51DK7qPcknV/8rdIbjLmYtruMLeVVMIwlg4sEZoqreTtGt34MO7KqfMhyIPPXSfQVAIX6J+rF9M4ltAdvAfggvbm4g0IBbJXyNNAaU5HhPRXN/VhNgYkJH7zWH3qM70H+Zmc0jj1xTcJ0RLwhVhRavFYHWmFZ/63WrBpNDk0V55F9zQ3IvnpQ9xSvXSBxIydoW0cwlqyO9XRur0fI1fPAR/Uw5NQ6fxmcc3RzfN8KaHq x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB5600.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(396003)(346002)(39860400002)(376002)(366004)(451199015)(7696005)(26005)(64756008)(52536014)(107886003)(66946007)(83380400001)(478600001)(55016003)(9686003)(186003)(6506007)(5660300002)(110136005)(8936002)(71200400001)(966005)(66476007)(41300700001)(76116006)(66556008)(54906003)(8676002)(4326008)(316002)(2906002)(66446008)(33656002)(122000001)(86362001)(38100700002)(82960400001)(84970400001)(38070700005)(81973001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: VvxQmruzoCTMGaKKPZwtIqMOXGd8PLotsaWGaOry/pU56gOlcUYf3WpVtKOTdbbtpz8v1tFTnluaXcAYBY/U5XMG3aUrQY33RlIIno+60b0KDlo9pNR2Zv83bB+8zrTnZXJZd9pHIfc3Rk3223Ucr/3Tn92ibRDsbqX/jt2WzSXDYwv3D8IaV2fp7jJYOmmjlQxtkPSvNqUqSasVu0YygIphDg+BGPPx3WV0LoYKGtF/QDDTeO304WhEx0d7mUO2E2sROrWGlA2whHjhtb8fSLChlFhcBvIgBrlXygyym8zB+vE4J+zLS1k8Xgtz7ybKF6kONraXb+kAVx3jgI+cTfSWcknpLqK8GKI92yeQjYgZyYWpnbma2nNLx5YRFoL44Kha93pmd74Sy7UtxD6QemkuJumDszODT1aYGEObLZc7/czTxH//OlFAcpgv0P1z17uUCigG6ecExUkw4UP7E+Cx+Nq5kY4lPQ1P2tjX+Tuan2C9z9p2MD4Sw7ioY1yuDz2Zw7vQJ/yvtswxnzhPV240sqtmZxdIU/0GwuVyqVkJdlpoRy/Q+NBBB3zqUCotZbPxUcm2ewud5MrwjiBn09Cdjo3J4PxjUViI0FYauUcKZkFSwYexGayClb3ieONzu85thxQnsuMj6lpVgxO5VaDdLysZYQ/+iiAy1xBZ9LAt2s4/giWNlrQEOTQpcSpDQ0ejjYF7XlnFkcCU/MmIcRQkr4WTCnqMjTeUbg+Z/CgNMQgW8SWuDpmjxNWeQZFC1UGXiu4HGhHSU4oyQxxrcxyPoSx8Vvr/e/A9x3EY+bDbmJ3ZZUgVGiJy3VGhFDEVZrV8QDI9lpgpxHIyjYe+VsWg6c7lcfNlXqfSmXOEk+6iVeCDKSchtPRLupZYTxJUPyye2F3TWNXpNfYCuF79JiIvWglXyMf66rwYVkNcwA+4uC5KFz774pr5UZv7yXk55r222WtaAU6e7FagoZ2UF0wGRgrrmK2auDPyzsf6kIfJpeWDDZsBFn17t447KLCckyrHzNZSz2xEGuQvLkXqjFDVNM7QJxMWu2vE18Jq8nRCVG9CVyhpFPxgbqkFa9S1POQ0Bhdr6xJBLW2H+h4I48GuGCGUC7Ls3Y07vyv7LNmk1lFoHHfSYHyRmInr7f9u001dQyfSykZQc4GQBClxoymU/zPYcovt0HHiQ8feuOOXOWhBsHWie1eKyPaHbPcjjaiEWdYVB5Ia46Uihhg+GlfkQ2a7Uk0X2hyHsXbzVGO3wJesOoAjP5kmwY39vfsj3nNU0bTBDwjOeL4v46fkxQASd0gRhlQtvMddOil5+GzV19eeXlOgsBElPQrYljl2tpOsOY3BeH6u6PWILReIfV4FOrfX7MrRY6UAPbxcSAI+W46PQE9KmVa5iMUgWEzJb9qkZ8f1eSnI/grp4Zicf+swiJUSjjxJaaq0vJLpZTbcoCr/sOqUkCsuEmwmYEU4HdrlU5kwxXjaVxnS7McEBsNM9wb9/AVxWDqHv0vg88uhwfbrDp4c8X+i+48bxt5rRBEWUUH1VCWu/9wlwiXqVxvkdpCqvKCyG8v21bua/U5ZR9afOJ5Esb2D7Q2/rcYS MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5600.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 286cda97-57cb-4090-d694-08dab306dba2 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2022 01:52:06.2091 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: CS0pGPMckYp+t+OFjfR2MLMT5bHRU/Wa+u1VoqsAH6P5kMMN/DCPNvFsFa63jK/I8JbtJveNLzw9cmfymioF/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5086 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: "Cui, Lili via Gcc-patches" From: "Li, Pan2 via Gcc-patches" Reply-To: "Cui, Lili" Cc: "Lu, Hongjiu" , "Liu, Hongtao" , "gcc-patches@gcc.gnu.org" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747260204192635430?= X-GMAIL-MSGID: =?utf-8?q?1747260204192635430?= Hi Honza, Gentle ping https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601934.html gcc/ChangeLog * ipa-inline-analysis.cc (do_estimate_edge_time): Add function attribute judgement for INLINE_HINT_known_hot hint. gcc/testsuite/ChangeLog: * gcc.dg/ipa/inlinehint-6.c: New test. --- gcc/ipa-inline-analysis.cc | 13 ++++--- gcc/testsuite/gcc.dg/ipa/inlinehint-6.c | 47 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/inlinehint-6.c diff --git a/gcc/ipa-inline-analysis.cc b/gcc/ipa-inline-analysis.cc index 1ca685d1b0e..7bd29c36590 100644 --- a/gcc/ipa-inline-analysis.cc +++ b/gcc/ipa-inline-analysis.cc @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-utils.h" #include "cfgexpand.h" #include "gimplify.h" +#include "attribs.h" /* Cached node/edge growths. */ fast_call_summary *edge_growth_cache = NULL; @@ -249,15 +250,19 @@ do_estimate_edge_time (struct cgraph_edge *edge, sreal *ret_nonspec_time) hints = estimates.hints; } - /* When we have profile feedback, we can quite safely identify hot - edges and for those we disable size limits. Don't do that when - probability that caller will call the callee is low however, since it + /* When we have profile feedback or function attribute, we can quite safely + identify hot edges and for those we disable size limits. Don't do that + when probability that caller will call the callee is low however, since it may hurt optimization of the caller's hot path. */ - if (edge->count.ipa ().initialized_p () && edge->maybe_hot_p () + if ((edge->count.ipa ().initialized_p () && edge->maybe_hot_p () && (edge->count.ipa () * 2 > (edge->caller->inlined_to ? edge->caller->inlined_to->count.ipa () : edge->caller->count.ipa ()))) + || (lookup_attribute ("hot", DECL_ATTRIBUTES (edge->caller->decl)) + != NULL + && lookup_attribute ("hot", DECL_ATTRIBUTES (edge->callee->decl)) + != NULL)) hints |= INLINE_HINT_known_hot; gcc_checking_assert (size >= 0); diff --git a/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c b/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c new file mode 100644 index 00000000000..1f3be641c6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c @@ -0,0 +1,47 @@ +/* { dg-options "-O3 -c -fdump-ipa-inline-details -fno-early-inlining -fno-ipa-cp" } */ +/* { dg-add-options bind_pic_locally } */ + +#define size_t long long int + +struct A +{ + size_t f1, f2, f3, f4; +}; +struct C +{ + struct A a; + size_t b; +}; +struct C x; + +__attribute__((hot)) struct C callee (struct A *a, struct C *c) +{ + c->a=(*a); + + if((c->b + 7) & 17) + { + c->a.f1 = c->a.f2 + c->a.f1; + c->a.f2 = c->a.f3 - c->a.f2; + c->a.f3 = c->a.f2 + c->a.f3; + c->a.f4 = c->a.f2 - c->a.f4; + c->b = c->a.f2; + + } + return *c; +} + +__attribute__((hot)) struct C caller (size_t d, size_t e, size_t f, size_t g, struct C *c) +{ + struct A a; + a.f1 = 1 + d; + a.f2 = e; + a.f3 = 12 + f; + a.f4 = 68 + g; + if (c->b > 0) + return callee (&a, c); + else + return *c; +} + +/* { dg-final { scan-ipa-dump "known_hot" "inline" } } */ +