1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +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
MCParser [Support] Make line-number cache robust against access patterns. 2018-04-07 00:44:02 +00:00
CMakeLists.txt
ConstantPools.cpp
ELFObjectWriter.cpp
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
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
MCAsmMacro.cpp
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
MCCodeEmitter.cpp
MCCodePadder.cpp
MCCodeView.cpp
MCContext.cpp
MCDwarf.cpp Reapply "[DWARFv5] Emit file 0 to the line table." 2018-03-29 17:16:41 +00:00
MCELFObjectTargetWriter.cpp
MCELFStreamer.cpp
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
MCNullStreamer.cpp
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
MCSchedule.cpp [MC] Fix -Wmissing-field-initializer warning after r329067. 2018-04-03 13:52:26 +00:00
MCSection.cpp
MCSectionCOFF.cpp
MCSectionELF.cpp
MCSectionMachO.cpp
MCSectionWasm.cpp
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
MCTargetOptions.cpp
MCValue.cpp
MCWasmObjectTargetWriter.cpp
MCWasmStreamer.cpp
MCWin64EH.cpp
MCWinCOFFStreamer.cpp
MCWinEH.cpp
StringTableBuilder.cpp
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