SuccessChanges

Summary

  1. [libunwind] Combine dl_iterate_phdr codepaths for DWARF and EHABI (details)
  2. [libunwind] Optimize dl_iterate_phdr's findUnwindSectionsByPhdr (details)
  3. [JSON] Add error reporting to fromJSON and ObjectMapper (details)
Commit b16d6653c01cee37f51a98dd4092c4ef302c47a5 by rprichard
[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
The file was modifiedlibunwind/src/AddressSpace.hpp (diff)
The file was modifiedlibunwind/test/frameheadercache_test.pass.cpp (diff)
Commit 881aba7071c6e4cc2417e875ca5027ec7c0a92a3 by rprichard
[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
The file was modifiedlibunwind/src/AddressSpace.hpp (diff)
Commit fa69b608063eecba76fb35d167b063cbfe532c28 by sam.mccall
[JSON] Add error reporting to fromJSON and ObjectMapper

Translating between JSON objects and C++ strutctures is common.
From experience in clangd, fromJSON/ObjectMapper work well and save a lot of
code, but aren't adopted elsewhere at least partly due to total lack of error
reporting beyond "ok"/"bad".

The recently-added error model should be rich enough for most applications.
It requires tracking the path within the root object and reporting local
errors at appropriate places.
To do this, we exploit the fact that the call graph of recursive
parse functions mirror the structure of the JSON itself.
The current path is represented as a linked list of segments, each of which is
on the stack as a parameter. Concretely, fromJSON now looks like:
  bool fromJSON(const Value&, T&, Path);

Beyond the signature change, this is reasonably unobtrusive: building
the path segments is mostly handled by ObjectMapper and the vector<T> fromJSON.
However the root caller of fromJSON must now create a Root object to
store the errors, which is a little clunky.

I've added high-level parse<T>(StringRef) -> Expected<T>, but it's not
general enough to be the primary interface I think (at least, not usable in
clangd).

All existing users (mostly just clangd) are updated in this patch,
making this change backwards-compatible is a bit hairy.

Differential Revision: https://reviews.llvm.org/D88103
The file was modifiedllvm/unittests/Support/JSONTest.cpp (diff)
The file was modifiedclang-tools-extra/clangd/ClangdLSPServer.h (diff)
The file was modifiedclang-tools-extra/clangd/Protocol.h (diff)
The file was modifiedclang-tools-extra/clangd/index/Index.cpp (diff)
The file was modifiedclang-tools-extra/clangd/ClangdLSPServer.cpp (diff)
The file was modifiedlldb/source/Utility/StructuredData.cpp (diff)
The file was modifiedllvm/include/llvm/Support/JSON.h (diff)
The file was modifiedclang-tools-extra/clangd/index/Index.h (diff)
The file was modifiedclang-tools-extra/clangd/Protocol.cpp (diff)
The file was modifiedclang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp (diff)
The file was modifiedllvm/lib/Analysis/TFUtils.cpp (diff)