LLVM 19.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/DenseSet.h"
15#include <functional>
16
17namespace llvm {
18class Error;
19class GlobalValue;
20class Metadata;
21class Module;
22class StructType;
23class TrackingMDRef;
24class Type;
25
26class IRMover {
27 struct StructTypeKeyInfo {
28 struct KeyTy {
32 KeyTy(const StructType *ST);
33 bool operator==(const KeyTy &that) const;
34 bool operator!=(const KeyTy &that) const;
35 };
36 static StructType *getEmptyKey();
37 static StructType *getTombstoneKey();
38 static unsigned getHashValue(const KeyTy &Key);
39 static unsigned getHashValue(const StructType *ST);
40 static bool isEqual(const KeyTy &LHS, const StructType *RHS);
41 static bool isEqual(const StructType *LHS, const StructType *RHS);
42 };
43
44 /// Type of the Metadata map in \a ValueToValueMapTy.
46
47public:
49 // The set of opaque types is the composite module.
50 DenseSet<StructType *> OpaqueStructTypes;
51
52 // The set of identified but non opaque structures in the composite module.
54
55 public:
56 void addNonOpaque(StructType *Ty);
58 void addOpaque(StructType *Ty);
59 StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
60 bool hasType(StructType *Ty);
61 };
62
63 IRMover(Module &M);
64
65 typedef std::function<void(GlobalValue &)> ValueAdder;
68
69 /// Move in the provide values in \p ValuesToLink from \p Src.
70 ///
71 /// - \p AddLazyFor is a call back that the IRMover will call when a global
72 /// value is referenced by one of the ValuesToLink (transitively) but was
73 /// not present in ValuesToLink. The GlobalValue and a ValueAdder callback
74 /// are passed as an argument, and the callback is expected to be called
75 /// if the GlobalValue needs to be added to the \p ValuesToLink and linked.
76 /// Pass nullptr if there's no work to be done in such cases.
77 /// - \p IsPerformingImport is true when this IR link is to perform ThinLTO
78 /// function importing from Src.
79 Error move(std::unique_ptr<Module> Src, ArrayRef<GlobalValue *> ValuesToLink,
80 LazyCallback AddLazyFor, bool IsPerformingImport);
81 Module &getModule() { return Composite; }
82
83private:
84 Module &Composite;
85 IdentifiedStructTypeSet IdentifiedStructTypes;
86 MDMapT SharedMDs; ///< A Metadata map to use for all calls to \a move().
87};
88
89} // End llvm namespace
90
91#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
RelocType Type
Definition: COFFYAML.cpp:391
This file defines the DenseSet and SmallDenseSet classes.
This file provides a collection of function (or more generally, callable) type erasure utilities supp...
Machine Check Debug Module
#define P(N)
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:271
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
void switchToNonOpaque(StructType *Ty)
Definition: IRMover.cpp:1747
StructType * findNonOpaque(ArrayRef< Type * > ETypes, bool IsPacked)
Definition: IRMover.cpp:1761
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:1792
Module & getModule()
Definition: IRMover.h:81
std::function< void(GlobalValue &)> ValueAdder
Definition: IRMover.h:65
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Class to represent struct types.
Definition: DerivedTypes.h:216
unique_function is a type-erasing functor similar to std::function.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
@ Add
Sum of integers.
bool operator==(const KeyTy &that) const
Definition: IRMover.cpp:1703
bool operator!=(const KeyTy &that) const
Definition: IRMover.cpp:1707