]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Unroll the first get_sleb128 step to help the compiler optimize.
authorMark Wielaard <mjw@redhat.com>
Tue, 16 Dec 2014 09:53:22 +0000 (10:53 +0100)
committerMark Wielaard <mjw@redhat.com>
Wed, 17 Dec 2014 15:35:56 +0000 (16:35 +0100)
The common case is a single-byte. So no extra (max len) calculation is
necessary then.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/memory-access.h

index 8bc5d9d118a0bf30f1d9e9c5ed5d504f46e21da4..b1fb582b39d93e28d8576024b650a0782ad8d989 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-16  Mark Wielaard  <mjw@redhat.com>
+
+       * memory-access.h (__libdw_get_sleb128): Unroll the first step to help
+       the compiler optimize for the common single-byte case.
+
 2014-12-15  Josh Stone  <jistone@redhat.com>
 
        * memory-access.h (__libdw_max_len_leb128): New.
index 99c827af22bd33f1a5dc7b56f29212c84f72ec21..a53f79127a941a757c314ba639cffeff47dffafe 100644 (file)
@@ -94,9 +94,12 @@ __libdw_get_sleb128 (const unsigned char **addrp, const unsigned char *end)
 {
   int64_t acc = 0;
 
-  /* Unrolling 0 like uleb128 didn't prove to benefit optimization.  */
-  const size_t max = __libdw_max_len_leb128 (*addrp, end);
-  for (size_t i = 0; i < max; ++i)
+  /* Unroll the first step to help the compiler optimize
+     for the common single-byte case.  */
+  get_sleb128_step (acc, *addrp, 0);
+
+  const size_t max = __libdw_max_len_leb128 (*addrp - 1, end);
+  for (size_t i = 1; i < max; ++i)
     get_sleb128_step (acc, *addrp, i);
   /* Other implementations set VALUE to INT_MAX in this
      case.  So we better do this as well.  */