llvm-6502/include/llvm/IR
Chandler Carruth 69774fa1c4 [LPM] A targeted but somewhat horrible fix to the legacy pass manager's
querying of the pass registry.

The pass manager relies on the static registry of PassInfo objects to
perform all manner of its functionality. I don't understand why it does
much of this. My very vague understanding is that this registry is
touched both during static initialization *and* while each pass is being
constructed. As a consequence it is hard to make accessing it not
require a acquiring some lock. This lock ends up in the hot path of
setting up, tearing down, and invaliditing analyses in the legacy pass
manager.

On most systems you can observe this as a non-trivial % of the time
spent in 'ninja check-llvm'. However, I haven't really seen it be more
than 1% in extreme cases of compiling more real-world software,
including LTO.

Unfortunately, some of the GPU JITs are seeing this taking essentially
all of their time because they have very small IR running through
a small pass pipeline very many times (at least, this is the vague
understanding I have of it).

This patch tries to minimize the cost of looking up PassInfo objects by
leveraging the fact that the objects themselves are immutable and they
are allocated separately on the heap and so don't have their address
change. It also requires a change I made the last time I tried to debug
this problem which removed the ability to de-register a pass from the
registry. This patch creates a single access path to these objects
inside the PMTopLevelManager which memoizes the result of querying the
registry. This is somewhat gross as I don't really know if
PMTopLevelManager is the *right* place to put it, and I dislike using
a mutable member to memoize things, but it seems to work.

For long-lived pass managers this should completely eliminate
the cost of acquiring locks to look into the pass registry once the
memoized cache is warm. For 'ninja check' I measured about 1.5%
reduction in CPU time and in total time on a machine with 32 hardware
threads. For normal compilation, I don't know how much this will help,
sadly. We will still pay the cost while we populate the memoized cache.
I don't think it will hurt though, and for LTO or compiles with many
small functions it should still be a win. However, for tight loops
around a pass manager with many passes and small modules, this will help
tremendously. On the AArch64 backend I saw nearly 50% reductions in time
to complete 2000 cycles of spinning up and tearing down the pipeline.
Measurements from Owen of an actual long-lived pass manager show more
along the lines of 10% improvements.

Differential Revision: http://reviews.llvm.org/D7213

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227299 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-28 09:47:21 +00:00
..
Argument.h Provide convenient access to the zext/sext attributes of function arguments. NFC. 2014-08-05 05:43:41 +00:00
AssemblyAnnotationWriter.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Attributes.h Revert accidentally committed r217107 2014-09-03 23:38:05 +00:00
AutoUpgrade.h
BasicBlock.h Move helper for getting a terminating musttail call to BasicBlock 2014-08-12 00:05:15 +00:00
CallingConv.h X86: Implement the vectorcall calling convention 2014-10-28 01:29:26 +00:00
CallSite.h
CFG.h Standardize {pred,succ,use,user}_empty() 2015-01-13 03:46:47 +00:00
CMakeLists.txt
Comdat.h
Constant.h InstCombine: sub nsw %x, C -> add nsw %x, -C if C isn't INT_MIN 2014-08-22 16:41:23 +00:00
ConstantFolder.h
ConstantRange.h fix typos; remove names from comments; NFC 2015-01-09 17:11:51 +00:00
Constants.h Rename END_WITH_NULL to LLVM_END_WITH_NULL and move to Compiler.h 2014-11-04 01:12:21 +00:00
DataLayout.h Add a FIXME about preferred alignment to DataLayout. 2015-01-26 19:19:04 +00:00
DebugInfo.h DebugInfo: Fix use after return found by asan. 2015-01-24 19:55:23 +00:00
DebugLoc.h [cleanup] Re-sort all the #include lines in LLVM using 2015-01-14 11:23:27 +00:00
DerivedTypes.h Add params() to FunctionType. NFC. 2014-11-21 19:03:35 +00:00
DiagnosticInfo.h Use the DiagnosticHandler to print diagnostics when reading bitcode. 2015-01-10 00:07:30 +00:00
DiagnosticPrinter.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
DIBuilder.h IR: Remove MDNodeFwdDecl 2015-01-19 20:36:39 +00:00
Dominators.h [PM] Port domtree to the new pass manager (at last). 2015-01-14 10:19:28 +00:00
Function.h Revert GCStrategy ownership changes 2015-01-26 18:26:35 +00:00
GetElementPtrTypeIterator.h
GlobalAlias.h
GlobalObject.h Fix broken C++ mode comment 2014-11-05 01:36:22 +00:00
GlobalValue.h [cleanup] Re-sort all the #include lines in LLVM using 2015-01-14 11:23:27 +00:00
GlobalVariable.h
GVMaterializer.h Ask the module for its the identified types. 2014-12-03 07:18:23 +00:00
InlineAsm.h Reapply r215966, r215965, r215964, r215963, r215960, r215959, r215958, and r215957 2014-08-19 16:39:58 +00:00
InstIterator.h
InstrTypes.h Revert r220349 to re-instate r220277 with a fix for PR21330 -- quite 2014-11-25 08:20:27 +00:00
Instruction.def
Instruction.h Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
Instructions.h [cleanup] Re-sort all the #include lines in LLVM using 2015-01-14 11:23:27 +00:00
InstVisitor.h
IntrinsicInst.h IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
Intrinsics.h Intrinsics: introduce llvm_any_ty aka ValueType Any 2015-01-22 20:14:38 +00:00
Intrinsics.td BPF backend 2015-01-24 17:51:26 +00:00
IntrinsicsAArch64.td
IntrinsicsARM.td ARM: add @llvm.arm.space intrinsic for testing ConstantIslands. 2014-11-13 17:58:48 +00:00
IntrinsicsBPF.td BPF backend 2015-01-24 17:51:26 +00:00
IntrinsicsHexagon.td
IntrinsicsMips.td
IntrinsicsNVVM.td [NVPTX] Make the alignment an explicit argument to ldu/ldg 2014-08-29 15:30:20 +00:00
IntrinsicsPowerPC.td [PowerPC] Add VSX builtins for vec_div 2014-11-14 12:10:40 +00:00
IntrinsicsR600.td R600/SI: Add class intrinsic 2015-01-06 23:00:37 +00:00
IntrinsicsX86.td [X86] Use i8 immediate for comparison type on AVX512 packed integer instructions. This matches floating point equivalents. Includes autoupgrade support to convert old code. 2015-01-25 23:26:02 +00:00
IntrinsicsXCore.td
IRBuilder.h Some code improvements in Masked Load/Store. 2014-12-30 14:28:14 +00:00
IRPrintingPasses.h [PM] Switch the new pass manager to use a reference-based API for IR 2015-01-05 02:47:05 +00:00
LegacyPassManager.h Document that PassManager::add() may delete the pass right away. 2014-12-12 01:27:01 +00:00
LegacyPassManagers.h [LPM] A targeted but somewhat horrible fix to the legacy pass manager's 2015-01-28 09:47:21 +00:00
LegacyPassNameParser.h Refactoring cl::parser construction and initialization. 2015-01-22 21:01:12 +00:00
LLVMContext.h Introduce enum values for previously defined metadata types. (NFC) 2014-10-21 00:13:20 +00:00
Mangler.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
MDBuilder.h IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
Metadata.def IR: DwarfNode => DebugNode, NFC 2015-01-22 22:47:44 +00:00
Metadata.h IR: Change GenericDwarfNode::getHeader() to StringRef 2015-01-22 23:10:55 +00:00
MetadataTracking.h IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
Module.h [llvm link] Destroy ConstantArrays in LLVMContext if they are not used. 2015-01-20 19:24:59 +00:00
NoFolder.h
OperandTraits.h
Operator.h InstCombine: Don't assume that m_ZExt matches an Instruction 2014-11-01 23:46:05 +00:00
PassManager.h [PM] Push the debug option for the new pass manager into the opt tool 2015-01-13 22:42:38 +00:00
PassManagerInternal.h [PM] Remove the 'AnalysisManagerT' type parameter from numerous layers 2015-01-13 11:31:43 +00:00
PatternMatch.h InstSimplify: Optimize away pointless comparisons 2014-12-20 03:04:38 +00:00
PredIteratorCache.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Statepoint.h [GC] CodeGenPrep transform: simplify offsetable relocate 2015-01-14 23:27:07 +00:00
SymbolTableListTraits.h
TrackingMDRef.h Add a C++ marker to this header file. 2014-12-22 19:07:45 +00:00
Type.h Add and use Type::subtypes. NFC. 2014-11-24 20:44:36 +00:00
TypeBuilder.h
TypeFinder.h IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
Use.h
UseListOrder.h verify-uselistorder: Force -preserve-bc-use-list-order 2014-08-19 21:08:27 +00:00
User.h IR: Move NumOperands from User to Value, NFC 2014-10-15 20:39:05 +00:00
Value.h Standardize {pred,succ,use,user}_empty() 2015-01-13 03:46:47 +00:00
ValueHandle.h Fix UBSan error reports in ValueMapCallbackVH and AssertingVH<T> empty/tombstone keys generation. 2015-01-09 23:17:25 +00:00
ValueMap.h Fix UBSan error reports in ValueMapCallbackVH and AssertingVH<T> empty/tombstone keys generation. 2015-01-09 23:17:25 +00:00
ValueSymbolTable.h
Verifier.h [PM] Switch the new pass manager to use a reference-based API for IR 2015-01-05 02:47:05 +00:00