LLVM 22.0.0git
IRPartitionLayer.h
Go to the documentation of this file.
1//===- IRPartitionLayer.h - Partition IR module on lookup -------*- 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// JIT layer for breaking up modules into smaller submodules that only contains
10// looked up symbols.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_EXECUTIONENGINE_ORC_IRPARTITIONLAYER_H
15#define LLVM_EXECUTIONENGINE_ORC_IRPARTITIONLAYER_H
16
19#include "llvm/IR/Attributes.h"
20#include "llvm/IR/Constant.h"
21#include "llvm/IR/Constants.h"
22#include "llvm/IR/DataLayout.h"
23#include "llvm/IR/Function.h"
24#include "llvm/IR/GlobalAlias.h"
25#include "llvm/IR/GlobalValue.h"
27#include "llvm/IR/Instruction.h"
28#include "llvm/IR/Mangler.h"
29#include "llvm/IR/Module.h"
30#include "llvm/IR/Type.h"
32
33namespace llvm {
34namespace orc {
35
36/// A layer that breaks up IR modules into smaller submodules that only contains
37/// looked up symbols.
40
41public:
42 using GlobalValueSet = std::set<const GlobalValue *>;
43
44 /// Partitioning function.
46 std::function<std::optional<GlobalValueSet>(GlobalValueSet Requested)>;
47
48 /// Construct a IRPartitionLayer.
50
51 /// Off-the-shelf partitioning which compiles all requested symbols (usually
52 /// a single function at a time).
53 static std::optional<GlobalValueSet>
55
56 /// Off-the-shelf partitioning which compiles whole modules whenever any
57 /// symbol in them is requested.
58 static std::optional<GlobalValueSet>
60
61 /// Sets the partition function.
63
64 /// Emits the given module. This should not be called by clients: it will be
65 /// called by the JIT when a definition added via the add method is requested.
66 void emit(std::unique_ptr<MaterializationResponsibility> R,
67 ThreadSafeModule TSM) override;
68
69private:
70 void cleanUpModule(Module &M);
71
72 void expandPartition(GlobalValueSet &Partition);
73
74 void emitPartition(std::unique_ptr<MaterializationResponsibility> R,
77
78 IRLayer &BaseLayer;
80 SymbolLinkagePromoter PromoteSymbols;
81};
82
83} // namespace orc
84} // namespace llvm
85
86#endif
This file contains the simple types necessary to represent the attributes associated with functions a...
#define LLVM_ABI
Definition Compiler.h:213
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
An ExecutionSession represents a running JIT program.
Definition Core.h:1355
IRLayer(ExecutionSession &ES, const IRSymbolMapper::ManglingOptions *&MO)
Definition Layer.h:70
std::map< SymbolStringPtr, GlobalValue * > SymbolNameToDefinitionMap
Definition Layer.h:34
std::function< std::optional< GlobalValueSet >(GlobalValueSet Requested)> PartitionFunction
Partitioning function.
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emits the given module.
static std::optional< GlobalValueSet > compileWholeModule(GlobalValueSet Requested)
Off-the-shelf partitioning which compiles whole modules whenever any symbol in them is requested.
std::set< const GlobalValue * > GlobalValueSet
IRPartitionLayer(ExecutionSession &ES, IRLayer &BaseLayer)
Construct a IRPartitionLayer.
void setPartitionFunction(PartitionFunction Partition)
Sets the partition function.
friend class PartitioningIRMaterializationUnit
static std::optional< GlobalValueSet > compileRequested(GlobalValueSet Requested)
Off-the-shelf partitioning which compiles all requested symbols (usually a single function at a time)...
Promotes private symbols to global hidden, and renames to prevent clashes with other promoted symbols...
An LLVM Module together with a shared ThreadSafeContext.
This is an optimization pass for GlobalISel generic memory operations.