diff options
author | Mark Wielaard <mjw@redhat.com> | 2014-12-16 10:53:22 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2014-12-17 16:35:56 +0100 |
commit | 1b5477ddf360af0f6262c6f15a590448b4e1a65a (patch) | |
tree | 9044ead169c4e50905b140a2d3eda88e4537d6d0 /libdw | |
parent | 54662f13d14d59d44943543c48bdb21d50dd008d (diff) | |
download | elfutils-1b5477ddf360af0f6262c6f15a590448b4e1a65a.tar.gz |
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 <mjw@redhat.com>
Diffstat (limited to 'libdw')
-rw-r--r-- | libdw/ChangeLog | 5 | ||||
-rw-r--r-- | libdw/memory-access.h | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 8bc5d9d1..b1fb582b 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -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. 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. */ |