LLVM  13.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"
14 #include <functional>
15 
16 namespace llvm {
17 class Error;
18 class GlobalValue;
19 class Metadata;
20 class Module;
21 class StructType;
22 class TrackingMDRef;
23 class Type;
24 
25 class IRMover {
26  struct StructTypeKeyInfo {
27  struct KeyTy {
29  bool IsPacked;
30  KeyTy(ArrayRef<Type *> E, bool P);
31  KeyTy(const StructType *ST);
32  bool operator==(const KeyTy &that) const;
33  bool operator!=(const KeyTy &that) const;
34  };
35  static StructType *getEmptyKey();
36  static StructType *getTombstoneKey();
37  static unsigned getHashValue(const KeyTy &Key);
38  static unsigned getHashValue(const StructType *ST);
39  static bool isEqual(const KeyTy &LHS, const StructType *RHS);
40  static bool isEqual(const StructType *LHS, const StructType *RHS);
41  };
42 
43  /// Type of the Metadata map in \a ValueToValueMapTy.
45 
46 public:
48  // The set of opaque types is the composite module.
49  DenseSet<StructType *> OpaqueStructTypes;
50 
51  // The set of identified but non opaque structures in the composite module.
52  DenseSet<StructType *, StructTypeKeyInfo> NonOpaqueStructTypes;
53 
54  public:
55  void addNonOpaque(StructType *Ty);
56  void switchToNonOpaque(StructType *Ty);
57  void addOpaque(StructType *Ty);
59  bool hasType(StructType *Ty);
60  };
61 
62  IRMover(Module &M);
63 
65 
66  /// Move in the provide values in \p ValuesToLink from \p Src.
67  ///
68  /// - \p AddLazyFor is a call back that the IRMover will call when a global
69  /// value is referenced by one of the ValuesToLink (transitively) but was
70  /// not present in ValuesToLink. The GlobalValue and a ValueAdder callback
71  /// are passed as an argument, and the callback is expected to be called
72  /// if the GlobalValue needs to be added to the \p ValuesToLink and linked.
73  /// - \p IsPerformingImport is true when this IR link is to perform ThinLTO
74  /// function importing from Src.
75  Error move(std::unique_ptr<Module> Src, ArrayRef<GlobalValue *> ValuesToLink,
76  std::function<void(GlobalValue &GV, ValueAdder Add)> AddLazyFor,
77  bool IsPerformingImport);
78  Module &getModule() { return Composite; }
79 
80 private:
81  Module &Composite;
82  IdentifiedStructTypeSet IdentifiedStructTypes;
83  MDMapT SharedMDs; ///< A Metadata map to use for all calls to \a move().
84 };
85 
86 } // End llvm namespace
87 
88 #endif
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::IRMover::StructTypeKeyInfo::KeyTy::ETypes
ArrayRef< Type * > ETypes
Definition: IRMover.h:28
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::IRMover::IdentifiedStructTypeSet::findNonOpaque
StructType * findNonOpaque(ArrayRef< Type * > ETypes, bool IsPacked)
Definition: IRMover.cpp:1564
llvm::IRMover::StructTypeKeyInfo::KeyTy
Definition: IRMover.h:27
llvm::SIInstrFlags::IsPacked
@ IsPacked
Definition: SIDefines.h:88
llvm::IRMover::IdentifiedStructTypeSet::addNonOpaque
void addNonOpaque(StructType *Ty)
Definition: IRMover.cpp:1545
llvm::isEqual
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Definition: GCNRegPressure.cpp:55
llvm::IRMover::getModule
Module & getModule()
Definition: IRMover.h:78
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::IRMover::StructTypeKeyInfo::KeyTy::KeyTy
KeyTy(ArrayRef< Type * > E, bool P)
Definition: IRMover.cpp:1500
llvm::IRMover::StructTypeKeyInfo::KeyTy::operator==
bool operator==(const KeyTy &that) const
Definition: IRMover.cpp:1506
llvm::IRMover::StructTypeKeyInfo::KeyTy::operator!=
bool operator!=(const KeyTy &that) const
Definition: IRMover.cpp:1510
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:471
llvm::IRMover::IdentifiedStructTypeSet::addOpaque
void addOpaque(StructType *Ty)
Definition: IRMover.cpp:1558
DenseSet.h
that
Reference model for inliner Oz decision policy Note that
Definition: README.txt:2
llvm::IRMover::IdentifiedStructTypeSet::hasType
bool hasType(StructType *Ty)
Definition: IRMover.cpp:1571
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::IRMover
Definition: IRMover.h:25
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::IRMover::StructTypeKeyInfo::KeyTy::IsPacked
bool IsPacked
Definition: IRMover.h:29
llvm::IRMover::IRMover
IRMover(Module &M)
Definition: IRMover.cpp:1578
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::DenseMap< const Metadata *, TrackingMDRef >
llvm::IRMover::ValueAdder
std::function< void(GlobalValue &)> ValueAdder
Definition: IRMover.h:64
ArrayRef.h
TemplateParamKind::Type
@ Type
llvm::IRMover::move
Error move(std::unique_ptr< Module > Src, ArrayRef< GlobalValue * > ValuesToLink, std::function< void(GlobalValue &GV, ValueAdder Add)> AddLazyFor, bool IsPerformingImport)
Move in the provide values in ValuesToLink from Src.
Definition: IRMover.cpp:1595
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:212
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::IRMover::IdentifiedStructTypeSet
Definition: IRMover.h:47
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
LineType::Metadata
@ Metadata
llvm::IRMover::IdentifiedStructTypeSet::switchToNonOpaque
void switchToNonOpaque(StructType *Ty)
Definition: IRMover.cpp:1550