From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76364 invoked by alias); 4 Jan 2020 00:05:21 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 76356 invoked by uid 89); 4 Jan 2020 00:05:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=U*goblock, H*i:sk:ca99127, sk:goblock, goblockmarvellcom X-HELO: mx0b-0016f401.pphosted.com Received: from mx0b-0016f401.pphosted.com (HELO mx0b-0016f401.pphosted.com) (67.231.156.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Jan 2020 00:05:18 +0000 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 003Nxrxj027709; Fri, 3 Jan 2020 16:05:16 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : mime-version; s=pfpt0818; bh=6OZ5o3EPpWZCl75ekB6SLu5pI3C3Fordoz0fO6KP/fg=; b=LaptEIiPiyT7l5O1vy0/QkIWswYatpiiWZTVUhUxcmM8tntCr/jbim5mMAxLUp+W+MFU oKDR13ofassgrGKTxpwNGfUSv1LjeywjY6Vy1GYCEPyU8+HEb8oPZdhtB6DfiMuAnbqu W1lYgwVpC3fcpkOoN07R8Apj/fCGFRM4yIhnfDfjvXw2vijx81ZjGdDZJiEtxfGpY4Lk L42u5k1xNzkjVl4UmiPOHtfJLd6bG0RxhZtZepRSvBIhbZJxx9/AC/knySykNcWKDUNl sK3Z2m6R2kCpEuj+2MQttc8jUVVbCONBmCupVSbGBVe1VmNG+qdRaQEl5dQurrUl5aKB dw== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2x67ett92e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 03 Jan 2020 16:05:16 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 3 Jan 2020 16:05:14 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.101) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 3 Jan 2020 16:05:14 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f4dq4a19wBCBKZHyiCnEkZhoRsmyjgf/dpDs+H4JJJXNP7P8oZ2Lt6Y1Z/xnug3IylJg2o8cCOcpKIwOMny6fO8sfHq0N4SgbLgb2h9qcUj6BAESvqvS3ethMFuDJI7N6vKtU4dz8CbhrkH/dbnpIgWvpR6VSHOfAneRPynEqHHezzJ9bwnU1CN4x2125TQi4fxzvVm65pZjx4228Zd52GZ/TgBtaMu4KoFLKYTpaavKUgX8gXe1e45BO2kng+/4f6Sq7r4191tnjvQpMzJWTbidLBd+I/csyvdRG/ElkkU09+qhEm84f9wdtTyaSc8WZVhPslfv8v6mfYYLdpDDWg== 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-SenderADCheck; bh=6OZ5o3EPpWZCl75ekB6SLu5pI3C3Fordoz0fO6KP/fg=; b=Ka0W7zkGY+uW9CrzDB0VKvsE2olGmqw6Z0kZlUPbS8m6U8E3NDhVKHUh4ZbK8N+zlfqNo0X1NkYg1SJmczX/qHLlxbSYzBbLf4uvRHz2jwDstResO7+qDv1ffBtRcHRVLtYmUsTB1b2NeP4wbewf8z3YN0OpPooLDFMNEcR3e6Iwdnq40RoYsitEjGbUTvQBs0NApneuC1evwTQ9ISBKl99i5qe4ifwbZskN8P+AEevNQHDclCx0tIGap/29IgZGlh2TU+pj5WAF2Eq/rXXieH7k9DtC7Y24nc7XvVZrbB/wx+LbzRO3BqySvrK4F31vlmIV2CWSm+vFi2cggJ2vLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6OZ5o3EPpWZCl75ekB6SLu5pI3C3Fordoz0fO6KP/fg=; b=bwfFWuoXRU8KJyJRRF2ZOHmoDeyz/draiLei43+7uX2jigL+YaYxYlb+8OXOqJwP+fbh9UTlLvtKYWCzWDRchgM0GHBKiTN28qvjuY0ZgdhkWa9VTa/8EngytHHsZ4G5yAO0VkgdFdRlaNviAd2pJLO3Go8yn3UnpkQpZhP93/Q= Received: from BY5PR18MB3409.namprd18.prod.outlook.com (10.255.139.29) by BY5PR18MB3364.namprd18.prod.outlook.com (10.255.136.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Sat, 4 Jan 2020 00:05:13 +0000 Received: from BY5PR18MB3409.namprd18.prod.outlook.com ([fe80::78fc:5d39:5d71:40fb]) by BY5PR18MB3409.namprd18.prod.outlook.com ([fe80::78fc:5d39:5d71:40fb%4]) with mapi id 15.20.2602.012; Sat, 4 Jan 2020 00:05:13 +0000 From: Gary Oblock To: David Malcolm , "gcc@gcc.gnu.org" Subject: Re: [EXT] Re: Mechanism to get at function information seems not to work Date: Sat, 04 Jan 2020 00:05:00 -0000 Message-ID: References: , In-Reply-To: x-ms-oob-tlc-oobclassifiers: OLM:4125; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iXF/og7G7SDKPtQb8NDfkjim3arSy8gCXFii09wWYy2NRldS79XHJFNm/EtoCqN4KxU1echzAu8C98ZT9D1EbQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2020-01/txt/msg00018.txt.bz2 Thanks David, I'll give it a try. By the way, I'm trying to force one partition with "-flto-partition=3Done" I'm not sure if that makes a difference. Gary ________________________________ From: David Malcolm Sent: Friday, January 3, 2020 3:52 PM To: Gary Oblock ; gcc@gcc.gnu.org Subject: [EXT] Re: Mechanism to get at function information seems not to wo= rk External Email ---------------------------------------------------------------------- On Fri, 2020-01-03 at 23:02 +0000, Gary Oblock wrote: > I'm having some grief attempting to get at the local definitions > in LTO (more about the options used later.) > > Here's the sequence of code in my optimization (part of attempt > at structure reorganization optimizations.) > > cgraph_node* node; > FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) > { > tree decl; > unsigned i; > struct function *fn =3D DECL_STRUCT_FUNCTION ( node->decl); > > // I'm assuming it's obvious what my debugging macros do... > DEBUG( "fn %p\n", fn); > DEBUG_F( print_generic_decl, stderr, node->decl, (dump_flags_t)- > 1); > DEBUG( "\n"); > // I don't know why this is coming up null.... but I'll > // skip it for now because causes a crash. > if( fn =3D=3D NULL ) > { > continue; > } > > FOR_EACH_LOCAL_DECL ( fn, i, decl) > { > : > > What it returns is: > > fn 0xffffb0fc9210 > static intD.xxxx max1.constprop.0D.xxxx (struct type_t *); > fn 0xffffb0fc9370 > static doubleD.xxxx max2.constprop.0D.xxxx (struct type_t *); > fn (nil) > static intD.xxxx mainD.xxxx (void); > fn (nil) > static struct type_t * setupD.xxxx (size_t); > [...snip...] > Here is how I compile them: > > GCC=3D/home/goblock/str-reorg-gcc-build-dir/install/bin/gcc > OPTIONS=3D"-O2 -flto -flto-partition=3Done -fipa-structure-reorg" > > $GCC $OPTIONS -c main.c > $GCC $OPTIONS -c aux.c > $GCC $OPTIONS -o exe main.o aux.o > > ./exe > > I'm wondering if this is a fundamental issue, if there's a bug > or perhaps I'm doing something dumb. I any advice is appreciated > here because my only real alternative here is insanely ugly. This looks like the same issue as one I ran into when trying to add LTO support to the static analyzer [1]. AIUI the LTO infrastructure partitions the functions in a kind of sharding operation. There's no guarantee for any given partition's invocation of lto1 that it has a particular function body. I fixed this in the analyzer by putting this loop at the top of the pass: /* If using LTO, ensure that the cgraph nodes have function bodies. */ cgraph_node *node; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) node->get_untransformed_body (); which seems to fix it for me (my pass then goes on to do a non-trivial interprocedural traversal, so it needs to have all the function bodies present first). I'm not sure if this is the correct fix for your issue, but it worked for my pass (I'm just using "-flto", FWIW). Hope this is helpful Dave [1] https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__gcc.gnu.org_wiki= _DavidMalcolm_StaticAnalyzer&d=3DDwICaQ&c=3DnKjWec2b6R0mOyPaz7xtfQ&r=3DHVs3= hYm_BnTtuG8V-km21WLujN2g6AKxQlP-LTQPUQI&m=3DPLNbIn26nObhyevJgxSrCwF8SwZVo7I= LB5s5Uu2DmRk&s=3DquDOZbDeR-DxertzdPRUzHiBYIXOpQ6cRmjMsvC9EbE&e=3D