LLVM 20.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"
31
32namespace llvm {
33namespace orc {
34
35/// A layer that breaks up IR modules into smaller submodules that only contains
36/// looked up symbols.
37class IRPartitionLayer : public IRLayer {
39
40public:
41 using GlobalValueSet = std::set<const GlobalValue *>;
42
43 /// Partitioning function.
45 std::function<std::optional<GlobalValueSet>(GlobalValueSet Requested)>;
46
47 /// Construct a IRPartitionLayer.
49
50 /// Off-the-shelf partitioning which compiles all requested symbols (usually
51 /// a single function at a time).
52 static std::optional<GlobalValueSet>
54
55 /// Off-the-shelf partitioning which compiles whole modules whenever any
56 /// symbol in them is requested.
57 static std::optional<GlobalValueSet>
59
60 /// Sets the partition function.
62
63 /// Emits the given module. This should not be called by clients: it will be
64 /// called by the JIT when a definition added via the add method is requested.
65 void emit(std::unique_ptr<MaterializationResponsibility> R,
66 ThreadSafeModule TSM) override;
67
68private:
69 void cleanUpModule(Module &M);
70
71 void expandPartition(GlobalValueSet &Partition);
72
73 void emitPartition(std::unique_ptr<MaterializationResponsibility> R,
76
77 IRLayer &BaseLayer;
79 SymbolLinkagePromoter PromoteSymbols;
80};
81
82} // namespace orc
83} // namespace llvm
84
85#endif
This file contains the simple types necessary to represent the attributes associated with functions a...
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:65
An ExecutionSession represents a running JIT program.
Definition: Core.h:1339
Interface for layers that accept LLVM IR.
Definition: Layer.h:67
std::map< SymbolStringPtr, GlobalValue * > SymbolNameToDefinitionMap
Definition: Layer.h:33
A layer that breaks up IR modules into smaller submodules that only contains looked up symbols.
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::function< std::optional< GlobalValueSet >(GlobalValueSet Requested)> PartitionFunction
Partitioning function.
std::set< const GlobalValue * > GlobalValueSet
void setPartitionFunction(PartitionFunction Partition)
Sets the partition function.
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.
Definition: AddressRanges.h:18