From patchwork Thu Feb 13 13:03:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 38027 Received: (qmail 101541 invoked by alias); 13 Feb 2020 13:03:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 101533 invoked by uid 89); 13 Feb 2020 13:03:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Feb 2020 13:03:03 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 79E05AE41 for ; Thu, 13 Feb 2020 13:03:01 +0000 (UTC) Date: Thu, 13 Feb 2020 14:03:01 +0100 (CET) From: Richard Biener To: gdb-patches@sourceware.org cc: Tom de Vries Subject: [PATCH] Speedup lnp_state_machine::handle_special_opcode Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 I see for some program at gdb startup Samples: 102K of event 'cycles:pu', Event count (approx.): 91710925103 Overhead Command Shared Object Symbol 15.21% gdb gdb [.] lnp_state_machine::handle_special where the divisions are the places we stall. The following micro-optimizes things but it smells like m_line_header->line_range is constant, likewise probably m_line_header->maximum_ops_per_instruction so eventually the divisions could be avoided completely with some lookup table. Well. Micro-optimizing with the patch below improves things (don't expect [load] CSE over the gdbarch_adjust_dwarf2_line call). Care to pick up this one-time patch without myself becoming familiar with gdb testing & patch submission? Thanks, Richard. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7edbd9d7df..e74383e01d 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19812,16 +19812,16 @@ void lnp_state_machine::handle_special_opcode (unsigned char op_code) { unsigned char adj_opcode = op_code - m_line_header->opcode_base; - CORE_ADDR addr_adj = (((m_op_index - + (adj_opcode / m_line_header->line_range)) + unsigned char adj_opcode_d = adj_opcode / m_line_header->line_range; + unsigned char adj_opcode_r = adj_opcode % m_line_header->line_range; + CORE_ADDR addr_adj = (((m_op_index + adj_opcode_d) / m_line_header->maximum_ops_per_instruction) * m_line_header->minimum_instruction_length); m_address += gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true); - m_op_index = ((m_op_index + (adj_opcode / m_line_header->line_range)) + m_op_index = ((m_op_index + adj_opcode_d) % m_line_header->maximum_ops_per_instruction); - int line_delta = (m_line_header->line_base - + (adj_opcode % m_line_header->line_range)); + int line_delta = m_line_header->line_base + adj_opcode_r; advance_line (line_delta); record_line (false); m_discriminator = 0;