1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00
llvm-mirror/lib/MC
Graydon Hoare cded1d3751 [Support] Make line-number cache robust against access patterns.
Summary:
The LLVM SourceMgr class (which is used indirectly by Swift, though not Clang)
has a routine for looking up line numbers of SMLocs. This routine uses a
shared, special-purpose cache that handles exactly one access pattern
efficiently: looking up the line number of an SMLoc that points into the same
buffer as the last query made to the SourceMgr, at a location in the buffer at
or ahead of the last query.

When this works it's fine, but when it fails it's catastrophic for performancer:
one recent out-of-order access from a Swift utility routine ran for tens of
seconds, spending 99% of its time repeatedly scanning buffers for '\n'.

This change removes the shared cache from the SourceMgr and installs a new
cache in each SrcBuffer. The per-SrcBuffer caches are also "full", in the sense
that rather than caching a single last-query pointer, they cache _all_ the
line-ending offsets, in a binary-searchable array, such that once it's
populated (on first access), all subsequent access patterns run at the same
speed.

Performance measurements I've done show this is actually a little bit faster on
real codebases (though only a couple fractions of a percent). Memory usage is
up by a few tens to hundreds of bytes per SrcBuffer that has a line lookup done
on it; I've attempted to minimize this by using dynamic selection of integer
sized when storing offset arrays. But the main motive here is to
make-impossible the cases we don't always see, that show up by surprise when
there is an out-of-order access pattern.

Reviewers: jordan_rose

Reviewed By: jordan_rose

Subscribers: probinson, llvm-commits

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

llvm-svn: 329470
2018-04-07 00:44:02 +00:00
..
MCDisassembler Shrink various scheduling tables by using narrower types. 2018-02-23 19:32:56 +00:00
MCParser [Support] Make line-number cache robust against access patterns. 2018-04-07 00:44:02 +00:00
CMakeLists.txt [Asm] Add debug printing for assembler macros 2018-03-06 14:07:01 +00:00
ConstantPools.cpp
ELFObjectWriter.cpp Delay creating an alias for @@@. 2018-03-09 18:42:25 +00:00
LLVMBuild.txt Add a build dependency from libMC to libDebugInfoCodeView to match the reality of header dependencies here 2018-03-26 23:48:52 +00:00
MachObjectWriter.cpp [MC] Issue error message when data region is not terminated 2018-02-12 07:19:05 +00:00
MCAsmBackend.cpp
MCAsmInfo.cpp [DEBUGINFO] Add option that allows to disable emission of flags in .loc directives. 2018-04-03 17:28:55 +00:00
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
MCAsmInfoWasm.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCAsmMacro.cpp [Asm] Fix another layering violation in assmebly macro dumping 2018-03-06 16:51:17 +00:00
MCAsmStreamer.cpp [DEBUGINFO] Add option that allows to disable emission of flags in .loc directives. 2018-04-03 17:28:55 +00:00
MCAssembler.cpp [MC] Fix assembler infinite loop on EH table using LEB padding. 2018-02-01 00:25:19 +00:00
MCCodeEmitter.cpp
MCCodePadder.cpp
MCCodeView.cpp [CodeView] Add line numbers for inlined call sites 2018-01-18 22:55:43 +00:00
MCContext.cpp [DebugInfo] Support DWARF v5 source code embedding extension 2018-02-23 23:01:06 +00:00
MCDwarf.cpp Reapply "[DWARFv5] Emit file 0 to the line table." 2018-03-29 17:16:41 +00:00
MCELFObjectTargetWriter.cpp
MCELFStreamer.cpp Delay creating an alias for @@@. 2018-03-09 18:42:25 +00:00
MCExpr.cpp [WebAssembly] Added initial AsmParser implementation. 2018-03-20 20:06:35 +00:00
MCFragment.cpp
MCInst.cpp [RISCV] Tablegen-driven Instruction Compression. 2018-04-06 21:07:05 +00:00
MCInstPrinter.cpp
MCInstrAnalysis.cpp
MCInstrDesc.cpp
MCLabel.cpp
MCLinkerOptimizationHint.cpp
MCMachObjectTargetWriter.cpp
MCMachOStreamer.cpp Don't create MCFillFragment directly. 2018-01-09 21:55:10 +00:00
MCNullStreamer.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCObjectFileInfo.cpp Re-commit r329179 after fixing build&test issues 2018-04-04 14:42:14 +00:00
MCObjectStreamer.cpp Re-land r327620 "[CodeView] Initial support for emitting S_BLOCK32 symbols for lexical scopes" 2018-03-15 21:24:04 +00:00
MCObjectWriter.cpp
MCRegisterInfo.cpp [MC] Handle unknown literal register numbers in .cfi_* directives 2017-12-01 21:44:27 +00:00
MCSchedule.cpp [MC] Fix -Wmissing-field-initializer warning after r329067. 2018-04-03 13:52:26 +00:00
MCSection.cpp
MCSectionCOFF.cpp
MCSectionELF.cpp CodeGen: support an extension to pass linker options on ELF 2018-01-30 16:29:29 +00:00
MCSectionMachO.cpp
MCSectionWasm.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCStreamer.cpp Reapply "[DWARFv5] Emit file 0 to the line table." 2018-03-29 17:16:41 +00:00
MCSubtargetInfo.cpp [MC] fix documentation comments; NFC 2018-03-22 15:23:21 +00:00
MCSymbol.cpp
MCSymbolELF.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCTargetOptions.cpp
MCValue.cpp
MCWasmObjectTargetWriter.cpp
MCWasmStreamer.cpp [WebAssembly] Add first claass symbol table to wasm objects 2018-02-23 05:08:34 +00:00
MCWin64EH.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCWinCOFFStreamer.cpp Reland "Emit Function IDs table for Control Flow Guard" 2018-01-09 23:49:30 +00:00
MCWinEH.cpp
StringTableBuilder.cpp [DWARFv5] Emit .debug_line_str (in a non-DWO file). 2018-02-06 20:29:21 +00:00
SubtargetFeature.cpp
WasmObjectWriter.cpp [WebAssembly] Allow for the creation of user-defined custom sections 2018-04-05 17:01:39 +00:00
WinCOFFObjectWriter.cpp [MC] Always emit relocations for same-section function references 2018-03-14 19:24:32 +00:00