[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Bitcode / Reader / MetadataLoader.h
blob709800850f0dd6fd1f9123a5c42101ada782c8f4
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.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_BITCODE_READER_METADATALOADER_H
14 #define LLVM_LIB_BITCODE_READER_METADATALOADER_H
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/Support/Error.h"
19 #include <functional>
20 #include <memory>
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;
32 /// Helper class that handles loading Metadatas and keeping them available.
33 class MetadataLoader {
34 class MetadataLoaderImpl;
35 std::unique_ptr<MetadataLoaderImpl> Pimpl;
36 Error parseMetadata(bool ModuleLevel);
38 public:
39 ~MetadataLoader();
40 MetadataLoader(BitstreamCursor &Stream, Module &TheModule,
41 BitcodeReaderValueList &ValueList, bool IsImporting,
42 std::function<Type *(unsigned)> getTypeByID);
43 MetadataLoader &operator=(MetadataLoader &&);
44 MetadataLoader(MetadataLoader &&);
46 // Parse a module metadata block
47 Error parseModuleMetadata() { return parseMetadata(true); }
49 // Parse a function metadata block
50 Error parseFunctionMetadata() { return parseMetadata(false); }
52 /// Set the mode to strip TBAA metadata on load.
53 void setStripTBAA(bool StripTBAA = true);
55 /// Return true if the Loader is stripping TBAA metadata.
56 bool isStrippingTBAA();
58 // Return true there are remaining unresolved forward references.
59 bool hasFwdRefs() const;
61 /// Return the given metadata, creating a replaceable forward reference if
62 /// necessary.
63 Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
65 /// Return the DISubprogram metadata for a Function if any, null otherwise.
66 DISubprogram *lookupSubprogramForFunction(Function *F);
68 /// Parse a `METADATA_ATTACHMENT` block for a function.
69 Error parseMetadataAttachment(
70 Function &F, const SmallVectorImpl<Instruction *> &InstructionList);
72 /// Parse a `METADATA_KIND` block for the current module.
73 Error parseMetadataKinds();
75 unsigned size() const;
76 void shrinkTo(unsigned N);
78 /// Perform bitcode upgrades on llvm.dbg.* calls.
79 void upgradeDebugIntrinsics(Function &F);
83 #endif // LLVM_LIB_BITCODE_READER_METADATALOADER_H