LLVM 24.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/Support/Error.h"
17
18#include <functional>
19#include <memory>
20
21namespace llvm {
22class BasicBlock;
24class BitstreamCursor;
25class DISubprogram;
26class Function;
27class Instruction;
28class MDNode;
29class Metadata;
30class Module;
31class Type;
32template <typename T> class ArrayRef;
33
34typedef std::function<Type *(unsigned)> GetTypeByIDTy;
35
36typedef std::function<unsigned(unsigned, unsigned)> GetContainedTypeIDTy;
37
38typedef std::function<void(Metadata **, unsigned, GetTypeByIDTy,
41
47
48/// Helper class that handles loading Metadatas and keeping them available.
51 std::unique_ptr<MetadataLoaderImpl> Pimpl;
52 Error parseMetadata(bool ModuleLevel);
53
54public:
56 MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
57 BitcodeReaderValueList &ValueList, bool IsImporting,
58 MetadataLoaderCallbacks Callbacks);
61
62 // Parse a module metadata block
64
65 // Parse a function metadata block
67
68 /// Set the mode to strip TBAA metadata on load.
69 void setStripTBAA(bool StripTBAA = true);
70
71 /// Return true if the Loader is stripping TBAA metadata.
72 bool isStrippingTBAA();
73
74 // Return true there are remaining unresolved forward references.
75 bool hasFwdRefs() const;
76
77 /// Return the given metadata, creating a replaceable forward reference if
78 /// necessary.
79 Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
80
81 /// Return the DISubprogram metadata for a Function if any, null otherwise.
83
84 /// Parse a `METADATA_ATTACHMENT` block for a function.
86 ArrayRef<Instruction *> InstructionList);
87
88 /// Parse a `METADATA_KIND` block for the current module.
90
91 unsigned size() const;
92 void shrinkTo(unsigned N);
93
94 /// Perform bitcode upgrades on llvm.dbg.* calls.
96
97 /// Mark any domains in \p ScopeList that don't have a disjointness
98 /// flag as non-disjoint. Returns the original list if there are no changes.
100};
101}
102
103#endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H
#define F(x, y, z)
Definition MD5.cpp:54
static bool parseMetadata(const StringRef &Input, uint64_t &FunctionHash, uint32_t &Attributes)
Parse Input that contains metadata.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
Subprogram description. Uses SubclassData1.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Metadata node.
Definition Metadata.h:1081
MDNode * upgradeAliasScopeList(MDNode *ScopeList)
Mark any domains in ScopeList that don't have a disjointness flag as non-disjoint.
MetadataLoader(BitstreamCursor &Stream, Module &TheModule, BitcodeReaderValueList &ValueList, bool IsImporting, MetadataLoaderCallbacks Callbacks)
Metadata * getMetadataFwdRefOrLoad(unsigned Idx)
Return the given metadata, creating a replaceable forward reference if necessary.
void upgradeDebugIntrinsics(Function &F)
Perform bitcode upgrades on llvm.dbg.* calls.
void shrinkTo(unsigned N)
Error parseMetadataKinds()
Parse a METADATA_KIND block for the current module.
void setStripTBAA(bool StripTBAA=true)
Set the mode to strip TBAA metadata on load.
bool isStrippingTBAA()
Return true if the Loader is stripping TBAA metadata.
Error parseMetadataAttachment(Function &F, ArrayRef< Instruction * > InstructionList)
Parse a METADATA_ATTACHMENT block for a function.
DISubprogram * lookupSubprogramForFunction(Function *F)
Return the DISubprogram metadata for a Function if any, null otherwise.
MetadataLoader & operator=(MetadataLoader &&)
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
This is an optimization pass for GlobalISel generic memory operations.
std::function< Type *(unsigned)> GetTypeByIDTy
std::function< unsigned(unsigned, unsigned)> GetContainedTypeIDTy
std::function< void(Metadata **, unsigned, GetTypeByIDTy, GetContainedTypeIDTy)> MDTypeCallbackTy
#define N
GetContainedTypeIDTy GetContainedTypeID
std::optional< MDTypeCallbackTy > MDType