LLVM  14.0.0git
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 Function;
27 class Instruction;
28 class Metadata;
29 class Module;
30 class Type;
31 
32 /// Helper class that handles loading Metadatas and keeping them available.
34  class MetadataLoaderImpl;
35  std::unique_ptr<MetadataLoaderImpl> Pimpl;
36  Error parseMetadata(bool ModuleLevel);
37 
38 public:
40  MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
41  BitcodeReaderValueList &ValueList, bool IsImporting,
42  std::function<Type *(unsigned)> getTypeByID);
45 
46  // Parse a module metadata block
48 
49  // Parse a function metadata block
51 
52  /// Set the mode to strip TBAA metadata on load.
53  void setStripTBAA(bool StripTBAA = true);
54 
55  /// Return true if the Loader is stripping TBAA metadata.
56  bool isStrippingTBAA();
57 
58  // Return true there are remaining unresolved forward references.
59  bool hasFwdRefs() const;
60 
61  /// Return the given metadata, creating a replaceable forward reference if
62  /// necessary.
63  Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
64 
65  /// Return the DISubprogram metadata for a Function if any, null otherwise.
67 
68  /// Parse a `METADATA_ATTACHMENT` block for a function.
70  Function &F, const SmallVectorImpl<Instruction *> &InstructionList);
71 
72  /// Parse a `METADATA_KIND` block for the current module.
74 
75  unsigned size() const;
76  void shrinkTo(unsigned N);
77 
78  /// Perform bitcode upgrades on llvm.dbg.* calls.
80 };
81 }
82 
83 #endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H
llvm::MetadataLoader::lookupSubprogramForFunction
DISubprogram * lookupSubprogramForFunction(Function *F)
Return the DISubprogram metadata for a Function if any, null otherwise.
Definition: MetadataLoader.cpp:2349
llvm::MetadataLoader::MetadataLoaderImpl
Definition: MetadataLoader.cpp:418
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::Function
Definition: Function.h:62
llvm::MetadataLoader::parseMetadataKinds
Error parseMetadataKinds()
Parse a METADATA_KIND block for the current module.
Definition: MetadataLoader.cpp:2358
Error.h
llvm::MetadataLoader::operator=
MetadataLoader & operator=(MetadataLoader &&)
Definition: MetadataLoader.cpp:2322
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::BitstreamCursor
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
Definition: BitstreamReader.h:340
llvm::MetadataLoader::shrinkTo
void shrinkTo(unsigned N)
Definition: MetadataLoader.cpp:2369
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::MetadataLoader::hasFwdRefs
bool hasFwdRefs() const
Definition: MetadataLoader.cpp:2341
llvm::MetadataLoader::size
unsigned size() const
Definition: MetadataLoader.cpp:2368
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
parseMetadata
static bool parseMetadata(const StringRef &Input, uint64_t &FunctionHash, uint32_t &Attributes)
Parse Input that contains metadata.
Definition: SampleProfReader.cpp:106
llvm::MetadataLoader
Helper class that handles loading Metadatas and keeping them available.
Definition: MetadataLoader.h:33
llvm::MetadataLoader::MetadataLoader
MetadataLoader(BitstreamCursor &Stream, Module &TheModule, BitcodeReaderValueList &ValueList, bool IsImporting, std::function< Type *(unsigned)> getTypeByID)
Definition: MetadataLoader.cpp:2330
llvm::BitcodeReaderValueList
Definition: ValueList.h:28
llvm::MetadataLoader::~MetadataLoader
~MetadataLoader()
TemplateParamKind::Type
@ Type
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MetadataLoader::isStrippingTBAA
bool isStrippingTBAA()
Return true if the Loader is stripping TBAA metadata.
Definition: MetadataLoader.cpp:2366
llvm::MetadataLoader::parseModuleMetadata
Error parseModuleMetadata()
Definition: MetadataLoader.h:47
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::MetadataLoader::parseMetadataAttachment
Error parseMetadataAttachment(Function &F, const SmallVectorImpl< Instruction * > &InstructionList)
Parse a METADATA_ATTACHMENT block for a function.
Definition: MetadataLoader.cpp:2353
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::MetadataLoader::setStripTBAA
void setStripTBAA(bool StripTBAA=true)
Set the mode to strip TBAA metadata on load.
Definition: MetadataLoader.cpp:2362
llvm::MetadataLoader::parseFunctionMetadata
Error parseFunctionMetadata()
Definition: MetadataLoader.h:50
SmallVector.h
llvm::MetadataLoader::upgradeDebugIntrinsics
void upgradeDebugIntrinsics(Function &F)
Perform bitcode upgrades on llvm.dbg.* calls.
Definition: MetadataLoader.cpp:2371
N
#define N
LineType::Metadata
@ Metadata
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1826
llvm::SmallVectorImpl< Instruction * >
llvm::MetadataLoader::getMetadataFwdRefOrLoad
Metadata * getMetadataFwdRefOrLoad(unsigned Idx)
Return the given metadata, creating a replaceable forward reference if necessary.
Definition: MetadataLoader.cpp:2345
llvm::codeview::PublicSymFlags::Function
@ Function