LLVM 20.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;
23class BitcodeReaderValueList;
24class BitstreamCursor;
25class DISubprogram;
26class Function;
27class Instruction;
28class Metadata;
29class Module;
30class Type;
31template <typename T> class ArrayRef;
32
33typedef std::function<Type *(unsigned)> GetTypeByIDTy;
34
35typedef std::function<unsigned(unsigned, unsigned)> GetContainedTypeIDTy;
36
37typedef std::function<void(Metadata **, unsigned, GetTypeByIDTy,
40
44 std::optional<MDTypeCallbackTy> MDType;
45};
46
47/// Helper class that handles loading Metadatas and keeping them available.
50 std::unique_ptr<MetadataLoaderImpl> Pimpl;
51 Error parseMetadata(bool ModuleLevel);
52
53public:
55 MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
56 BitcodeReaderValueList &ValueList, bool IsImporting,
57 MetadataLoaderCallbacks Callbacks);
60
61 // Parse a module metadata block
63
64 // Parse a function metadata block
66
67 /// Set the mode to strip TBAA metadata on load.
68 void setStripTBAA(bool StripTBAA = true);
69
70 /// Return true if the Loader is stripping TBAA metadata.
71 bool isStrippingTBAA();
72
73 // Return true there are remaining unresolved forward references.
74 bool hasFwdRefs() const;
75
76 /// Return the given metadata, creating a replaceable forward reference if
77 /// necessary.
79
80 /// Return the DISubprogram metadata for a Function if any, null otherwise.
82
83 /// Parse a `METADATA_ATTACHMENT` block for a function.
85 ArrayRef<Instruction *> InstructionList);
86
87 /// Parse a `METADATA_KIND` block for the current module.
89
90 unsigned size() const;
91 void shrinkTo(unsigned N);
92
93 /// Perform bitcode upgrades on llvm.dbg.* calls.
95};
96}
97
98#endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H
RelocType Type
Definition: COFFYAML.cpp:391
dxil translate DXIL Translate Metadata
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
static bool parseMetadata(const StringRef &Input, uint64_t &FunctionHash, uint32_t &Attributes)
Parse Input that contains metadata.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
Subprogram description.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Helper class that handles loading Metadatas and keeping them available.
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.
unsigned size() const
MetadataLoader & operator=(MetadataLoader &&)
Root of the metadata hierarchy.
Definition: Metadata.h:62
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::function< Type *(unsigned)> GetTypeByIDTy
Definition: BitcodeReader.h:47
std::function< unsigned(unsigned, unsigned)> GetContainedTypeIDTy
Definition: BitcodeReader.h:49
std::function< void(Metadata **, unsigned, GetTypeByIDTy, GetContainedTypeIDTy)> MDTypeCallbackTy
Definition: BitcodeReader.h:57
ArrayRef(const T &OneElt) -> ArrayRef< T >
#define N
GetContainedTypeIDTy GetContainedTypeID
std::optional< MDTypeCallbackTy > MDType