[all-commits] [llvm/llvm-project] b16d66: [libunwind] Combine dl_iterate_phdr codepaths for ...

Ryan Prichard via All-commits all-commits at lists.llvm.org
Wed Sep 23 15:42:38 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b16d6653c01cee37f51a98dd4092c4ef302c47a5
      https://github.com/llvm/llvm-project/commit/b16d6653c01cee37f51a98dd4092c4ef302c47a5
  Author: Ryan Prichard <rprichard at google.com>
  Date:   2020-09-23 (Wed, 23 Sep 2020)

  Changed paths:
    M libunwind/src/AddressSpace.hpp
    M libunwind/test/frameheadercache_test.pass.cpp

  Log Message:
  -----------
  [libunwind] Combine dl_iterate_phdr codepaths for DWARF and EHABI

dl_iterate_phdr is used to search for unwind info provided by either
PT_GNU_EH_FRAME or PT_ARM_EXIDX. Most of the code between the two is
the same, so combine them, and factor out what's different into
checkForUnwindInfoSegment.

Details:
 - The FrameHeaderCache can now be enabled for ARM EHABI.
 - findUnwindSectionsByPhdr now finds the last PT_ARM_EXIDX rather than
   the first. There should only be one segment.
 - The dso_base and text_segment_length fields of UnwindInfoSections
   are now needed for dl_iterate_phdr when using EHABI, to hold the
   low and high PC values for a cache entry.

Reviewed By: compnerd, danielkiss, #libunwind, saugustine

Differential Revision: https://reviews.llvm.org/D87880


  Commit: 881aba7071c6e4cc2417e875ca5027ec7c0a92a3
      https://github.com/llvm/llvm-project/commit/881aba7071c6e4cc2417e875ca5027ec7c0a92a3
  Author: Ryan Prichard <rprichard at google.com>
  Date:   2020-09-23 (Wed, 23 Sep 2020)

  Changed paths:
    M libunwind/src/AddressSpace.hpp

  Log Message:
  -----------
  [libunwind] Optimize dl_iterate_phdr's findUnwindSectionsByPhdr

Currently, findUnwindSectionsByPhdr is slightly micro-optimized for the
case where the first callback has the target address, and is otherwise
very inefficient -- it decodes .eh_frame_hdr even when no PT_LOAD
matches the PC. (If the FrameHeaderCache is enabled, then the
micro-optimization only helps the first time unwind info is looked up.)

Instead, it makes more sense to optimize for the case where the
callback *doesn't* find the target address, so search for a PT_LOAD
segment first, and only look for the unwind info section if a matching
PT_LOAD is found.

This change helps on an Android benchmark with 100 shared objects,
where the DSO at the end of the dl_iterate_phdr list throws 10000
exceptions. Assuming the frame cache is disabled, this change cuts
about 30-40% off the benchmark's runtime.

Reviewed By: compnerd, saugustine, #libunwind

Differential Revision: https://reviews.llvm.org/D87881


Compare: https://github.com/llvm/llvm-project/compare/38de1c33a837...881aba7071c6


More information about the All-commits mailing list