From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70072.outbound.protection.outlook.com [40.107.7.72]) by sourceware.org (Postfix) with ESMTPS id EC37C384F4AB for ; Mon, 21 Nov 2022 21:04:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC37C384F4AB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hhXGAEmQGHfuYLFkvoRq2fUHlt+HRaNe/IogQQm1gqU=; b=ItYkfhbQqCuCUEUuuwFJlPB1KIG6mpKWtqEBmBPcFGFf1GiBt2E8gcuwh8FZCfCYCEQ3mufqXsiMbhzC/eooPw5rBTyi/rJYyd3XICDFH2cU9ZLizWx1gCe59mMDG+vqJc5JoNWnAgqZty0AW78bND3pJjFJNloGabsfX3dcDOM= Received: from AS9PR06CA0100.eurprd06.prod.outlook.com (2603:10a6:20b:465::11) by PAXPR08MB6398.eurprd08.prod.outlook.com (2603:10a6:102:12d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Mon, 21 Nov 2022 21:04:28 +0000 Received: from AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:465:cafe::8f) by AS9PR06CA0100.outlook.office365.com (2603:10a6:20b:465::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15 via Frontend Transport; Mon, 21 Nov 2022 21:04:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT049.mail.protection.outlook.com (100.127.140.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.8 via Frontend Transport; Mon, 21 Nov 2022 21:04:28 +0000 Received: ("Tessian outbound 58faf9791229:v130"); Mon, 21 Nov 2022 21:04:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 96a5939bb71594e2 X-CR-MTA-TID: 64aa7808 Received: from 45d6244b7fd5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9155891A-E322-470C-8506-6CBF0CDF0928.1; Mon, 21 Nov 2022 21:04:20 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 45d6244b7fd5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 21 Nov 2022 21:04:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UXnqUx0e8dOPD84WuoZqmTewZaYHAw2RfFDbyONUe3AP1cgJSG5fmOelty2Q6k3PIK08uu5h8wxuRLTRNO8bRueow0sOLSeZbdhtOOT9hxEYj3eamMlVJTZhhAe5rgO+vj7UTbb/DUKmbee0+sEKS5rJn3Qh+jW2Afypmi7Hm5HIzi1vdEICfbwDhlBGHxnUrcf9Ixu3RwG88reZrazn9mnEWI4MYOgXjbADZNHlfv2OIGsz6qd/xjda1RTMc4cB50pr2cGsIWwmhWw8QJIGZEo6U1Fwzjp33mOc9qFrFJ/BJ5FBm0BsTt6PMhLS8p4FbOB4t74Q9pW8OdYt0z3PjA== 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=hhXGAEmQGHfuYLFkvoRq2fUHlt+HRaNe/IogQQm1gqU=; b=N+UrLJWjwj/6Odt2p0wGBSfDDz64N3LK6iBMLOxUUUtESZNerrDMXDmR/QylbX3GgJ8BdGIsHnnliXlFP9K5B1goud/4Rl1WvRzqPBJXvZ7aj3g8mi4hnrSlRKYuvFFC5hBQ4C6z1mhog1faL5R2d8yDrEo/GWJoo9BJqXpW4bLw5De7IdQbt3cHj/J4zEIEJGfQQSZq5+PG49+Ak5+yV585z+GnnQaRABi6EUe/rybTJ2ad5gzAC9I/K6aAunXBKgHNegeK1J+VV33NlcVfxvbtKdIMfZ66uPU+W2QNKUVXkR5+Xtrwj8z3QQEv5iRqRwc/vE/c6zqBMT0t3QTjyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hhXGAEmQGHfuYLFkvoRq2fUHlt+HRaNe/IogQQm1gqU=; b=ItYkfhbQqCuCUEUuuwFJlPB1KIG6mpKWtqEBmBPcFGFf1GiBt2E8gcuwh8FZCfCYCEQ3mufqXsiMbhzC/eooPw5rBTyi/rJYyd3XICDFH2cU9ZLizWx1gCe59mMDG+vqJc5JoNWnAgqZty0AW78bND3pJjFJNloGabsfX3dcDOM= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by PAWPR08MB9640.eurprd08.prod.outlook.com (2603:10a6:102:2ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Mon, 21 Nov 2022 21:04:08 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c470:cc90:a9ad:6dd1]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c470:cc90:a9ad:6dd1%4]) with mapi id 15.20.5857.017; Mon, 21 Nov 2022 21:04:07 +0000 Message-ID: Date: Mon, 21 Nov 2022 21:04:06 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 4/4] gdb/arm: Use new dwarf2 function cache To: =?UTF-8?Q?Torbj=c3=b6rn_SVENSSON?= , gdb-patches@sourceware.org Cc: vanekt@volny.cz, Yvan Roux References: <20221118155252.113476-1-torbjorn.svensson@foss.st.com> <20221118155252.113476-5-torbjorn.svensson@foss.st.com> Content-Language: en-US From: Luis Machado In-Reply-To: <20221118155252.113476-5-torbjorn.svensson@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P265CA0013.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::9) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|PAWPR08MB9640:EE_|AM7EUR03FT049:EE_|PAXPR08MB6398:EE_ X-MS-Office365-Filtering-Correlation-Id: c3f8a812-6efb-405a-d5b1-08dacc03fa4c x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Yv+KPvUO4xufSdbs4DOyEOStjqvuRkZw3P7/e+TiSou65pwSgKG5IUUkHliDzLxrUjS58M1Kr7+7Uu/ksR7amHIKt+eVe0lQmWsJUUlTvXP35Sj+LmEoRN6jWd2Vlv6+dFBKfpVavKIoSU2Qc42q3xby+lz7ud2qGHyCCMq5EaMqdJMIKimcsjQSaxE0OIWemO5ltby0cxFo60gNP0me/ar5Le/d9n1uL6Ipw8usKjXpV7fJBiEuDiDePuTPySV93hvIybhIZlTlJZujMVouVbPHJ57jyb1bBazzPgGCRClhL5QSnskOUPlHto7kXyugRUizXhS1w+VqHC+ESlbqJjga9qRN6HFIBtkAxvFVaexZi2h1oZXcUu6Y3bFMhI5PmXXbs+4pxdurRFv+NU+1JMncw1l3P7imfvyX7z3SJZxLx6gskG5MgWnnVDVm/gXlKIlb28vJDwTONohT5PW+QC3w+Cp8wK654RWJQgLM5r9qe9DTrjt9azfQZHDo60EpIWHXm8cCa2TBFZ11NYXRgFonkgsgJfzqsithMGVERviWawSsaU02fAKMBewynZkHRrkBqG5DLHUL2t6uKvGRchscDsIT/Cfe5x3Par/QEw1zXJpWLUwQlVwEaTXMM1jUfo80oRX9UhkgbHKjyW1h5LR8jtuKcicjPAe87BucQntBS4YJ+h2zsjp3pSuD0qeoz/3GXnhADPv3y6Ht10tUMOTlkOFgCZ7UN/pZ1Y36M2I= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(451199015)(26005)(6486002)(31696002)(86362001)(6506007)(36756003)(83380400001)(38100700002)(6512007)(53546011)(2906002)(478600001)(186003)(2616005)(44832011)(8936002)(31686004)(41300700001)(8676002)(66556008)(66476007)(66946007)(5660300002)(4326008)(316002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9640 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e0684977-28f4-40fc-e114-08dacc03edd8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xJj/2ek+lrih0xUDffFXPCI1dcGPw+lp9KJV2Nbkvf18IRsqEnxrnYf00j/VzkzAHpfq2X69LRoKEhhBYTcdsqzmySXut0ERrLA2GhrGGb3DBwx7kU532vagl+iWix3wf6OGYLQ3fClDf0HczMJOybJ48kfJg9m6aPH3oN1vc7No71dRe/YQwHM+8iT4DpSvdx+N0RupPSGF8y6nKo9c6B+zkA+nZ6ywmgJjxxxP29/MDEeFVTPO8Tv/PmpN5eseZmdfADIdlnBrDBKwEeptPD+dopWXvUgOfYtHZEmHBGL8z2+IqKBZgWbQOry9RKAy+ghtuWjT/hi830snufqN58docCYLJ1vv+OUqTkj+aG/3k/cJKUzf0q2nLjwB7R9gGT/RJYZ17z2H753EQXecE2vfzjxBI/tD1+Q3/viAvZQgR2kzpWfdwvp2iq/snSYwiLRT7eA7MMa39gwIrEdw1h/LaqjyYGeOYwnbgz4nR06pnqwktLhHO3zlMXWFnP5LhsMePQ1E9VAv7ul+8h1sJthqHTr7nSv2of8qwtu0rR87H0X/Io0pSNM6OYVpBNi5szOP6Y9aIlwZ0DhYurGA3zCtNB18jnS5LGWcUo9+6cGiqJcb23vKjdVlkbeC5jbtv/wm/vOt0tKgb430C7mhyc+Da31bF2hXgOo0zhVsB1mok8hVUApU40v3dCW1wbCgwK6tE0Fp7XVXBw8hMTQsFuzNGLhrKuWp1LYLZRKmB2c= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(396003)(136003)(346002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(6506007)(26005)(356005)(81166007)(2906002)(86362001)(83380400001)(31696002)(36756003)(6486002)(478600001)(82310400005)(40460700003)(36860700001)(53546011)(6512007)(82740400003)(336012)(186003)(2616005)(47076005)(44832011)(8936002)(41300700001)(31686004)(40480700001)(8676002)(4326008)(5660300002)(70206006)(70586007)(316002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2022 21:04:28.1716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3f8a812-6efb-405a-d5b1-08dacc03fa4c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6398 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, On 11/18/22 15:52, Torbjörn SVENSSON wrote: > This patch resolves the performance issue reported in pr/29738 by > caching the values for the stack pointers for the inner frame. By > doing so, the impact can be reduced to checking the state and > returning the appropriate value. > > Signed-off-by: Torbjörn SVENSSON > Signed-off-by: Yvan Roux > --- > gdb/arm-tdep.c | 96 +++++++++++++++++++++++++++++++++----------------- > 1 file changed, 64 insertions(+), 32 deletions(-) > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index c011b2aa973..59cd0964d96 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -3953,6 +3953,18 @@ struct frame_base arm_normal_base = { > arm_normal_frame_base > }; > > +struct arm_dwarf2_prev_register_cache > +{ > + /* Cached value of the coresponding stack pointer for the inner frame. */ coresponding -> corresponding > + CORE_ADDR sp; > + CORE_ADDR msp; > + CORE_ADDR msp_s; > + CORE_ADDR msp_ns; > + CORE_ADDR psp; > + CORE_ADDR psp_s; > + CORE_ADDR psp_ns; > +}; > + Given SP is the cfa, do we need to cache it here? > static struct value * > arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache, > int regnum) > @@ -3961,6 +3973,48 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache, > arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > CORE_ADDR lr; > ULONGEST cpsr; > + struct arm_dwarf2_prev_register_cache *cache > + = (struct arm_dwarf2_prev_register_cache *) dwarf2_frame_get_fn_data ( > + this_frame, this_cache, arm_dwarf2_prev_register); > + > + if (!cache) > + { > + const unsigned int size = sizeof (struct arm_dwarf2_prev_register_cache); > + cache = (struct arm_dwarf2_prev_register_cache *) > + dwarf2_frame_allocate_fn_data (this_frame, this_cache, > + arm_dwarf2_prev_register, size); > + > + if (tdep->have_sec_ext) > + { > + cache->sp > + = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); We fetch ARM_SP_REGNUM in both legs of the conditional. How about moving it outside of the conditional blocks? > + > + cache->msp_s > + = get_frame_register_unsigned (this_frame, > + tdep->m_profile_msp_s_regnum); > + cache->msp_ns > + = get_frame_register_unsigned (this_frame, > + tdep->m_profile_msp_ns_regnum); > + cache->psp_s > + = get_frame_register_unsigned (this_frame, > + tdep->m_profile_psp_s_regnum); > + cache->psp_ns > + = get_frame_register_unsigned (this_frame, > + tdep->m_profile_psp_ns_regnum); > + } > + else if (tdep->is_m) > + { > + cache->sp > + = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); > + > + cache->msp > + = get_frame_register_unsigned (this_frame, > + tdep->m_profile_msp_regnum); > + cache->psp > + = get_frame_register_unsigned (this_frame, > + tdep->m_profile_psp_regnum); > + } > + } > > if (regnum == ARM_PC_REGNUM) > { > @@ -4000,33 +4054,18 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache, > > if (tdep->have_sec_ext) > { > - CORE_ADDR sp > - = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); > - CORE_ADDR msp_s > - = get_frame_register_unsigned (this_frame, > - tdep->m_profile_msp_s_regnum); > - CORE_ADDR msp_ns > - = get_frame_register_unsigned (this_frame, > - tdep->m_profile_msp_ns_regnum); > - CORE_ADDR psp_s > - = get_frame_register_unsigned (this_frame, > - tdep->m_profile_psp_s_regnum); > - CORE_ADDR psp_ns > - = get_frame_register_unsigned (this_frame, > - tdep->m_profile_psp_ns_regnum); > - > bool is_msp = (regnum == tdep->m_profile_msp_regnum) > - && (msp_s == sp || msp_ns == sp); > + && (cache->msp_s == cache->sp || cache->msp_ns == cache->sp); > bool is_msp_s = (regnum == tdep->m_profile_msp_s_regnum) > - && (msp_s == sp); > + && (cache->msp_s == cache->sp); > bool is_msp_ns = (regnum == tdep->m_profile_msp_ns_regnum) > - && (msp_ns == sp); > + && (cache->msp_ns == cache->sp); > bool is_psp = (regnum == tdep->m_profile_psp_regnum) > - && (psp_s == sp || psp_ns == sp); > + && (cache->psp_s == cache->sp || cache->psp_ns == cache->sp); > bool is_psp_s = (regnum == tdep->m_profile_psp_s_regnum) > - && (psp_s == sp); > + && (cache->psp_s == cache->sp); > bool is_psp_ns = (regnum == tdep->m_profile_psp_ns_regnum) > - && (psp_ns == sp); > + && (cache->psp_ns == cache->sp); > > override_with_sp_value = is_msp || is_msp_s || is_msp_ns > || is_psp || is_psp_s || is_psp_ns; > @@ -4034,17 +4073,10 @@ arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache, > } > else if (tdep->is_m) > { > - CORE_ADDR sp > - = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); > - CORE_ADDR msp > - = get_frame_register_unsigned (this_frame, > - tdep->m_profile_msp_regnum); > - CORE_ADDR psp > - = get_frame_register_unsigned (this_frame, > - tdep->m_profile_psp_regnum); > - > - bool is_msp = (regnum == tdep->m_profile_msp_regnum) && (sp == msp); > - bool is_psp = (regnum == tdep->m_profile_psp_regnum) && (sp == psp); > + bool is_msp = (regnum == tdep->m_profile_msp_regnum) > + && (cache->sp == cache->msp); > + bool is_psp = (regnum == tdep->m_profile_psp_regnum) > + && (cache->sp == cache->psp); > > override_with_sp_value = is_msp || is_psp; > } As we've discussed off-list, I think we can reduce the number of get_frame_register_unsigned calls we do for each call to arm_dwarf2_prev_register by using some conditionals.