mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
35f8930f4a
Each reference to an unresolved MDNode is expensive, since the RAUW support in MDNode uses a separate allocation and side map. Since a distinct MDNode doesn't require its operands on creation (unlike uniuqed nodes, there's no need to check for structural equivalence), use nullptr for any of its unresolved operands. Besides reducing the burden on MDNode maps, this can avoid allocating temporary MDNodes in the first place. We need some way to track operands. Invent DistinctMDOperandPlaceholder for this purpose, which is a Metadata subclass that holds an ID and points at its single user. DistinctMDOperandPlaceholder::replaceUseWith is just like RAUW, but its name highlights that there is only ever exactly one use. There is no support for moving (or, obviously, copying) these. Move support would be possible but expensive; leaving it unimplemented prevents user error. In the BitcodeReader I originally considered allocating on a BumpPtrAllocator and keeping a vector of pointers to them, and then I realized that std::deque implements exactly this. A couple of obvious follow-ups: - Change ValueEnumerator to emit distinct nodes first to take more advantage of this optimization. (How convenient... I think I might have a couple of patches for this.) - Change DIBuilder and its consumers (like CGDebugInfo in clang) to use something like this when constructing debug info in the first place. llvm-svn: 267270
125 lines
4.9 KiB
C++
125 lines
4.9 KiB
C++
//===- llvm/IR/Metadata.def - Metadata definitions --------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Macros for running through all types of metadata.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#if !(defined HANDLE_METADATA || defined HANDLE_METADATA_LEAF || \
|
|
defined HANDLE_METADATA_BRANCH || defined HANDLE_MDNODE_LEAF || \
|
|
defined HANDLE_MDNODE_LEAF_UNIQUABLE || defined HANDLE_MDNODE_BRANCH || \
|
|
defined HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE || \
|
|
defined HANDLE_SPECIALIZED_MDNODE_LEAF || \
|
|
defined HANDLE_SPECIALIZED_MDNODE_BRANCH)
|
|
#error "Missing macro definition of HANDLE_METADATA*"
|
|
#endif
|
|
|
|
// Handler for all types of metadata.
|
|
#ifndef HANDLE_METADATA
|
|
#define HANDLE_METADATA(CLASS)
|
|
#endif
|
|
|
|
// Handler for leaf nodes in the class hierarchy.
|
|
#ifndef HANDLE_METADATA_LEAF
|
|
#define HANDLE_METADATA_LEAF(CLASS) HANDLE_METADATA(CLASS)
|
|
#endif
|
|
|
|
// Handler for non-leaf nodes in the class hierarchy.
|
|
#ifndef HANDLE_METADATA_BRANCH
|
|
#define HANDLE_METADATA_BRANCH(CLASS) HANDLE_METADATA(CLASS)
|
|
#endif
|
|
|
|
// Handler for specialized and uniquable leaf nodes under MDNode. Defers to
|
|
// HANDLE_MDNODE_LEAF_UNIQUABLE if it's defined, otherwise to
|
|
// HANDLE_SPECIALIZED_MDNODE_LEAF.
|
|
#ifndef HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE
|
|
#ifdef HANDLE_MDNODE_LEAF_UNIQUABLE
|
|
#define HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(CLASS) \
|
|
HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)
|
|
#else
|
|
#define HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(CLASS) \
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS)
|
|
#endif
|
|
#endif
|
|
|
|
// Handler for leaf nodes under MDNode.
|
|
#ifndef HANDLE_MDNODE_LEAF_UNIQUABLE
|
|
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) HANDLE_MDNODE_LEAF(CLASS)
|
|
#endif
|
|
|
|
// Handler for leaf nodes under MDNode.
|
|
#ifndef HANDLE_MDNODE_LEAF
|
|
#define HANDLE_MDNODE_LEAF(CLASS) HANDLE_METADATA_LEAF(CLASS)
|
|
#endif
|
|
|
|
// Handler for non-leaf nodes under MDNode.
|
|
#ifndef HANDLE_MDNODE_BRANCH
|
|
#define HANDLE_MDNODE_BRANCH(CLASS) HANDLE_METADATA_BRANCH(CLASS)
|
|
#endif
|
|
|
|
// Handler for specialized leaf nodes under MDNode.
|
|
#ifndef HANDLE_SPECIALIZED_MDNODE_LEAF
|
|
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) HANDLE_MDNODE_LEAF(CLASS)
|
|
#endif
|
|
|
|
// Handler for specialized non-leaf nodes under MDNode.
|
|
#ifndef HANDLE_SPECIALIZED_MDNODE_BRANCH
|
|
#define HANDLE_SPECIALIZED_MDNODE_BRANCH(CLASS) HANDLE_MDNODE_BRANCH(CLASS)
|
|
#endif
|
|
|
|
HANDLE_METADATA_LEAF(MDString)
|
|
HANDLE_METADATA_BRANCH(ValueAsMetadata)
|
|
HANDLE_METADATA_LEAF(ConstantAsMetadata)
|
|
HANDLE_METADATA_LEAF(LocalAsMetadata)
|
|
HANDLE_METADATA_LEAF(DistinctMDOperandPlaceholder)
|
|
HANDLE_MDNODE_BRANCH(MDNode)
|
|
HANDLE_MDNODE_LEAF_UNIQUABLE(MDTuple)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DILocation)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIExpression)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DINode)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(GenericDINode)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DISubrange)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIEnumerator)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIScope)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIType)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIBasicType)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIDerivedType)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DICompositeType)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DISubroutineType)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIFile)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF(DICompileUnit)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DILocalScope)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DISubprogram)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DILexicalBlockBase)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DILexicalBlock)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DILexicalBlockFile)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DINamespace)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIModule)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DITemplateParameter)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DITemplateTypeParameter)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DITemplateValueParameter)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIVariable)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIGlobalVariable)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DILocalVariable)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIObjCProperty)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIImportedEntity)
|
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIMacroNode)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIMacro)
|
|
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIMacroFile)
|
|
|
|
#undef HANDLE_METADATA
|
|
#undef HANDLE_METADATA_LEAF
|
|
#undef HANDLE_METADATA_BRANCH
|
|
#undef HANDLE_MDNODE_LEAF
|
|
#undef HANDLE_MDNODE_LEAF_UNIQUABLE
|
|
#undef HANDLE_MDNODE_BRANCH
|
|
#undef HANDLE_SPECIALIZED_MDNODE_LEAF
|
|
#undef HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE
|
|
#undef HANDLE_SPECIALIZED_MDNODE_BRANCH
|