LLVM 22.0.0git
IRMover.h
Go to the documentation of this file.
1//===- IRMover.h ------------------------------------------------*- 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#ifndef LLVM_LINKER_IRMOVER_H
10#define LLVM_LINKER_IRMOVER_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/DenseSet.h"
18#include <functional>
19
20namespace llvm {
21class Error;
22class GlobalValue;
23class Metadata;
24class MDNode;
25class NamedMDNode;
26class Module;
27class StructType;
28class TrackingMDRef;
29class Type;
30
31class IRMover {
32 struct StructTypeKeyInfo {
33 struct KeyTy {
37 LLVM_ABI KeyTy(const StructType *ST);
38 LLVM_ABI bool operator==(const KeyTy &that) const;
39 LLVM_ABI bool operator!=(const KeyTy &that) const;
40 };
41 LLVM_ABI static StructType *getEmptyKey();
42 LLVM_ABI static StructType *getTombstoneKey();
43 LLVM_ABI static unsigned getHashValue(const KeyTy &Key);
44 LLVM_ABI static unsigned getHashValue(const StructType *ST);
45 LLVM_ABI static bool isEqual(const KeyTy &LHS, const StructType *RHS);
46 LLVM_ABI static bool isEqual(const StructType *LHS, const StructType *RHS);
47 };
48
49 /// Type of the Metadata map in \a ValueToValueMapTy.
51
52public:
54 // The set of opaque types is the composite module.
55 DenseSet<StructType *> OpaqueStructTypes;
56
57 // The set of identified but non opaque structures in the composite module.
59
60 public:
64 LLVM_ABI StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
65 LLVM_ABI bool hasType(StructType *Ty);
66 };
67
69
70 typedef std::function<void(GlobalValue &)> ValueAdder;
73
76
77 /// Move in the provide values in \p ValuesToLink from \p Src.
78 ///
79 /// - \p AddLazyFor is a call back that the IRMover will call when a global
80 /// value is referenced by one of the ValuesToLink (transitively) but was
81 /// not present in ValuesToLink. The GlobalValue and a ValueAdder callback
82 /// are passed as an argument, and the callback is expected to be called
83 /// if the GlobalValue needs to be added to the \p ValuesToLink and linked.
84 /// Pass nullptr if there's no work to be done in such cases.
85 /// - \p IsPerformingImport is true when this IR link is to perform ThinLTO
86 /// function importing from Src.
87 LLVM_ABI Error move(std::unique_ptr<Module> Src,
88 ArrayRef<GlobalValue *> ValuesToLink,
89 LazyCallback AddLazyFor, bool IsPerformingImport);
90 Module &getModule() { return Composite; }
91
92private:
93 Module &Composite;
94 IdentifiedStructTypeSet IdentifiedStructTypes;
95 MDMapT SharedMDs; ///< A Metadata map to use for all calls to \a move().
96 NamedMDNodesT NamedMDNodes; ///< Cache for IRMover::linkNamedMDNodes().
97};
98
99} // End llvm namespace
100
101#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file provides a collection of function (or more generally, callable) type erasure utilities supp...
#define P(N)
This file defines the SmallPtrSet class.
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
Implements a dense probed hash-table based set.
Definition DenseSet.h:261
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
LLVM_ABI void addNonOpaque(StructType *Ty)
Definition IRMover.cpp:1632
LLVM_ABI bool hasType(StructType *Ty)
Definition IRMover.cpp:1658
LLVM_ABI void switchToNonOpaque(StructType *Ty)
Definition IRMover.cpp:1637
LLVM_ABI void addOpaque(StructType *Ty)
Definition IRMover.cpp:1645
LLVM_ABI StructType * findNonOpaque(ArrayRef< Type * > ETypes, bool IsPacked)
Definition IRMover.cpp:1651
LLVM_ABI IRMover(Module &M)
Definition IRMover.cpp:1665
LLVM_ABI Error move(std::unique_ptr< Module > Src, ArrayRef< GlobalValue * > ValuesToLink, LazyCallback AddLazyFor, bool IsPerformingImport)
Move in the provide values in ValuesToLink from Src.
Definition IRMover.cpp:1682
Module & getModule()
Definition IRMover.h:90
std::function< void(GlobalValue &)> ValueAdder
Definition IRMover.h:70
DenseMap< const NamedMDNode *, SmallPtrSet< const MDNode *, 8 > > NamedMDNodesT
Definition IRMover.h:74
llvm::unique_function< void(GlobalValue &GV, ValueAdder Add)> LazyCallback
Definition IRMover.h:71
Metadata node.
Definition Metadata.h:1077
Root of the metadata hierarchy.
Definition Metadata.h:63
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A tuple of MDNodes.
Definition Metadata.h:1753
Class to represent struct types.
Tracking metadata reference.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
unique_function is a type-erasing functor similar to std::function.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Add
Sum of integers.
LLVM_ABI KeyTy(ArrayRef< Type * > E, bool P)
Definition IRMover.cpp:1588
LLVM_ABI bool operator==(const KeyTy &that) const
Definition IRMover.cpp:1594
LLVM_ABI bool operator!=(const KeyTy &that) const
Definition IRMover.cpp:1598