llvm-project/llvm/lib/DebugInfo/DWARF
Chandler Carruth 54a5ad3681 Rewrite the cached map used for locating the most precise DIE among
inlined subroutines for a given address.

This is essentially the hot path of llvm-symbolizer when extracting
inlined frames during symbolization. Previously, we would read every
subprogram and every inlined subroutine, building a std::map across the
entire PC space to the best DIE, and then do only a handful of queries
as we symbolized a backtrace. A huge fraction of the time was spent
building the map itself.

This patch changes it two a two-level system. First, we just build a map
from PC-interval to DWARF subprograms. These are required to be disjoint
and so constructing this is pretty easy. Second, we build a map *just*
for the inlined subroutines within the subprogram containing the query
address. This allows us to look at far fewer DIEs and build a *much*
smaller set of cached maps in the llvm-symbolizer case where only a few
address get symbolized during the entire run.

It also builds both interval maps in a very different way. It constructs
a single flat vector of pairs that maps from offset -> index. The
indices point into collections of DIE objects, but can also be
"tombstones" (-1) to mark gaps. In the case of subprograms, this mostly
just simplifies the data structure a bit. For inlined subroutines,
because we carefully split them as we build the map, we end up in many
cases having no holes and not having to store both start and stop
offsets.

Finally, the PC ranges for the inlined subroutines are compressed into
32-bits by making them relative to the base PC of the outer subprogram.
This means that if you have a single function body with over 2gb of
executable code in it, we will stop mapping address past the first 2gb
of that function into inlined subroutines and just give you the
subprogram. This doesn't seem like a problem. ;]

All of this combines to make llvm-symbolizer *well* over 2x faster for
symbolizing backtraces out of LLVM's unittests. Death-test heavy unit
tests are running >2x faster. I'm still going to look at completely
disabling symbolization there, but figured while I had a good benchmark
we should make symbolization a bit better.

Sadly, the logic to build the flat interval map for the inlined
subroutines is fairly complex. I'm not super happy about this and
welcome any simplifying suggestions.

Huge thanks to Dave Blaikie who helped walk me through what the various
things I needed to do in DWARF to make this work.

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

llvm-svn: 321345
2017-12-22 06:41:23 +00:00
..
CMakeLists.txt [dwarfdump] Pretty print location expressions and location lists 2017-08-29 21:41:21 +00:00
DWARFAbbreviationDeclaration.cpp [DWARFv5] Support DW_FORM_strp in the .debug_line header. 2017-11-07 19:57:12 +00:00
DWARFAcceleratorTable.cpp Silence a bunch of implicit fallthrough warnings 2017-12-19 22:05:25 +00:00
DWARFCompileUnit.cpp llvm-dwarfdump: implement --recurse-depth=<N> 2017-09-20 17:44:00 +00:00
DWARFContext.cpp [DWARF] Fix formatting bug with r321295. This fixes a MIPS buildbot failure. 2017-12-22 01:12:24 +00:00
DWARFDataExtractor.cpp [DebugInfo] - Fix for lld DWARF parsing of base address selection entries in range lists. 2017-09-04 10:30:39 +00:00
DWARFDebugAbbrev.cpp dwarfdump: Delay parsing abbreviations until they're needed 2017-09-19 15:13:55 +00:00
DWARFDebugArangeSet.cpp [DebugInfo] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-27 23:43:14 +00:00
DWARFDebugAranges.cpp [DebugInfo] Use shrink_to_fit to simplify code. NFCI. 2017-08-01 14:38:08 +00:00
DWARFDebugFrame.cpp [llvm-dwarfdump] - Teach tool to parse DW_CFA_GNU_args_size. 2017-10-16 10:26:17 +00:00
DWARFDebugInfoEntry.cpp [DWARF] NFC: DWARFDataExtractor combines relocs with DataExtractor. 2017-06-29 16:52:08 +00:00
DWARFDebugLine.cpp Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header." 2017-12-18 19:08:35 +00:00
DWARFDebugLoc.cpp [dwarfdump] Add support for -debug-loc=OFFSET 2017-09-27 09:33:36 +00:00
DWARFDebugMacro.cpp Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
DWARFDebugPubTable.cpp llvm-dwarfdump: Factor out the printing of the section header (NFC) 2017-09-15 17:39:50 +00:00
DWARFDebugRangeList.cpp [dwarfdump][NFC] Consistent printing of address ranges 2017-09-29 15:41:22 +00:00
DWARFDie.cpp dwarfdump: Add support for the --diff option. 2017-12-08 23:32:47 +00:00
DWARFExpression.cpp Remove redundant includes from lib/DebugInfo. 2017-12-13 21:30:49 +00:00
DWARFFormValue.cpp Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header." 2017-12-18 19:08:35 +00:00
DWARFGdbIndex.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
DWARFTypeUnit.cpp llvm-dwarfdump: implement --recurse-depth=<N> 2017-09-20 17:44:00 +00:00
DWARFUnit.cpp Rewrite the cached map used for locating the most precise DIE among 2017-12-22 06:41:23 +00:00
DWARFUnitIndex.cpp dwarfdump/symbolizer: Avoid loading unneeded CUs from a DWP 2017-09-19 18:36:11 +00:00
DWARFVerifier.cpp [dwarfdump] Fix off-by-one bug in accelerator table extractor. 2017-12-11 18:22:47 +00:00
LLVMBuild.txt [dwarfdump] Pretty print location expressions and location lists 2017-08-29 21:41:21 +00:00
SyntaxHighlighting.cpp [dwarfdump][NFC] Consistent errors and warnings with --verify 2017-09-29 09:33:31 +00:00
SyntaxHighlighting.h [dwarfdump][NFC] Consistent errors and warnings with --verify 2017-09-29 09:33:31 +00:00