summaryrefslogtreecommitdiffstats
path: root/libdw/memory-access.h
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2014-12-16 10:53:22 +0100
committerMark Wielaard <[email protected]>2014-12-17 16:35:56 +0100
commit1b5477ddf360af0f6262c6f15a590448b4e1a65a (patch)
tree9044ead169c4e50905b140a2d3eda88e4537d6d0 /libdw/memory-access.h
parent54662f13d14d59d44943543c48bdb21d50dd008d (diff)
libdw: Unroll the first get_sleb128 step to help the compiler optimize.
The common case is a single-byte. So no extra (max len) calculation is necessary then. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdw/memory-access.h')
-rw-r--r--libdw/memory-access.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/libdw/memory-access.h b/libdw/memory-access.h
index 99c827af..a53f7912 100644
--- a/libdw/memory-access.h
+++ b/libdw/memory-access.h
@@ -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. */