[gdb] Speedup lnp_state_machine::handle_special_opcode
authorRichard Biener <rguenther@suse.de>
Fri, 14 Feb 2020 07:32:53 +0000 (08:32 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 14 Feb 2020 07:32:53 +0000 (08:32 +0100)
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 this patch improves things
(don't expect [load] CSE over the gdbarch_adjust_dwarf2_line call).

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-02-14  Richard Biener  <rguenther@suse.de>

* dwarf2/read.c (lnp_state_machine::handle_special_opcode): Apply CSE
on expression with division operators.

gdb/ChangeLog
gdb/dwarf2/read.c

index eb3c0a836e1cdb2f1944f77b49a48d1f608486d2..a79aabcbeed6791d9ee389af766c4b6877fd3580 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-14  Richard Biener  <rguenther@suse.de>
+
+       * dwarf2/read.c (lnp_state_machine::handle_special_opcode): Apply CSE
+       on expression with division operators.
+
 2020-02-13  Alok Kumar Sharma  <AlokKumar.Sharma@amd.com>
 
        * MAINTAINERS (Write After Approval): Adding myself.
index 7edbd9d7dfa4b9d56143009139b1c3871b479816..e74383e01dccbe34feb60da15f1e148b54703a29 100644 (file)
@@ -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;
This page took 0.037944 seconds and 4 git commands to generate.