LLVM  8.0.1
MetadataLoader.h
Go to the documentation of this file.
1 //===-- Bitcode/Reader/MetadataLoader.h - Load Metadatas -------*- C++ -*-====//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class handles loading Metadatas.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_BITCODE_READER_METADATALOADER_H
15 #define LLVM_LIB_BITCODE_READER_METADATALOADER_H
16 
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/Support/Error.h"
19 
20 #include <functional>
21 #include <memory>
22 
23 namespace llvm {
24 class BitcodeReaderValueList;
25 class BitstreamCursor;
26 class DISubprogram;
27 class Error;
28 class Function;
29 class Instruction;
30 class Metadata;
31 class MDNode;
32 class Module;
33 class Type;
34 
35 /// Helper class that handles loading Metadatas and keeping them available.
37  class MetadataLoaderImpl;
38  std::unique_ptr<MetadataLoaderImpl> Pimpl;
39  Error parseMetadata(bool ModuleLevel);
40 
41 public:
43  MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
44  BitcodeReaderValueList &ValueList, bool IsImporting,
45  std::function<Type *(unsigned)> getTypeByID);
48 
49  // Parse a module metadata block
50  Error parseModuleMetadata() { return parseMetadata(true); }
51 
52  // Parse a function metadata block
53  Error parseFunctionMetadata() { return parseMetadata(false); }
54 
55  /// Set the mode to strip TBAA metadata on load.
56  void setStripTBAA(bool StripTBAA = true);
57 
58  /// Return true if the Loader is stripping TBAA metadata.
59  bool isStrippingTBAA();
60 
61  // Return true there are remaining unresolved forward references.
62  bool hasFwdRefs() const;
63 
64  /// Return the given metadata, creating a replaceable forward reference if
65  /// necessary.
66  Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
67 
68  /// Return the DISubprogram metadata for a Function if any, null otherwise.
70 
71  /// Parse a `METADATA_ATTACHMENT` block for a function.
73  Function &F, const SmallVectorImpl<Instruction *> &InstructionList);
74 
75  /// Parse a `METADATA_KIND` block for the current module.
77 
78  unsigned size() const;
79  void shrinkTo(unsigned N);
80 
81  /// Perform bitcode upgrades on llvm.dbg.* calls.
83 };
84 }
85 
86 #endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H
bool isStrippingTBAA()
Return true if the Loader is stripping TBAA metadata.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
unsigned size() const
F(f)
void upgradeDebugIntrinsics(Function &F)
Perform bitcode upgrades on llvm.dbg.* calls.
void setStripTBAA(bool StripTBAA=true)
Set the mode to strip TBAA metadata on load.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
Subprogram description.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
void shrinkTo(unsigned N)
Metadata * getMetadataFwdRefOrLoad(unsigned Idx)
Return the given metadata, creating a replaceable forward reference if necessary. ...
Helper class that handles loading Metadatas and keeping them available.
DISubprogram * lookupSubprogramForFunction(Function *F)
Return the DISubprogram metadata for a Function if any, null otherwise.
Error parseMetadataKinds()
Parse a METADATA_KIND block for the current module.
#define N
MetadataLoader & operator=(MetadataLoader &&)
MetadataLoader(BitstreamCursor &Stream, Module &TheModule, BitcodeReaderValueList &ValueList, bool IsImporting, std::function< Type *(unsigned)> getTypeByID)
Error parseMetadataAttachment(Function &F, const SmallVectorImpl< Instruction *> &InstructionList)
Parse a METADATA_ATTACHMENT block for a function.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
print Print MemDeps of function
Root of the metadata hierarchy.
Definition: Metadata.h:58
std::vector< uint32_t > Metadata
PAL metadata represented as a vector.