LLVM  10.0.0svn
MetadataLoader.h
Go to the documentation of this file.
1 //===-- Bitcode/Reader/MetadataLoader.h - Load Metadatas -------*- C++ -*-====//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This class handles loading Metadatas.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_BITCODE_READER_METADATALOADER_H
14 #define LLVM_LIB_BITCODE_READER_METADATALOADER_H
15 
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/Support/Error.h"
18 
19 #include <functional>
20 #include <memory>
21 
22 namespace llvm {
23 class BitcodeReaderValueList;
24 class BitstreamCursor;
25 class DISubprogram;
26 class Error;
27 class Function;
28 class Instruction;
29 class Metadata;
30 class MDNode;
31 class Module;
32 class Type;
33 
34 /// Helper class that handles loading Metadatas and keeping them available.
36  class MetadataLoaderImpl;
37  std::unique_ptr<MetadataLoaderImpl> Pimpl;
38  Error parseMetadata(bool ModuleLevel);
39 
40 public:
42  MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
43  BitcodeReaderValueList &ValueList, bool IsImporting,
44  std::function<Type *(unsigned)> getTypeByID);
47 
48  // Parse a module metadata block
49  Error parseModuleMetadata() { return parseMetadata(true); }
50 
51  // Parse a function metadata block
52  Error parseFunctionMetadata() { return parseMetadata(false); }
53 
54  /// Set the mode to strip TBAA metadata on load.
55  void setStripTBAA(bool StripTBAA = true);
56 
57  /// Return true if the Loader is stripping TBAA metadata.
58  bool isStrippingTBAA();
59 
60  // Return true there are remaining unresolved forward references.
61  bool hasFwdRefs() const;
62 
63  /// Return the given metadata, creating a replaceable forward reference if
64  /// necessary.
65  Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
66 
67  /// Return the DISubprogram metadata for a Function if any, null otherwise.
69 
70  /// Parse a `METADATA_ATTACHMENT` block for a function.
72  Function &F, const SmallVectorImpl<Instruction *> &InstructionList);
73 
74  /// Parse a `METADATA_KIND` block for the current module.
76 
77  unsigned size() const;
78  void shrinkTo(unsigned N);
79 
80  /// Perform bitcode upgrades on llvm.dbg.* calls.
82 };
83 }
84 
85 #endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H
bool isStrippingTBAA()
Return true if the Loader is stripping TBAA metadata.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
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:41
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:157
print Print MemDeps of function
Root of the metadata hierarchy.
Definition: Metadata.h:57