annotate include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h @ 128:c347d3398279 default tip

fix
author mir3636
date Wed, 06 Dec 2017 14:37:17 +0900
parents 803732b1fca8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 //===- CompileOnDemandLayer.h - Compile each function on demand -*- C++ -*-===//
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 //
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 //
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 // JIT layer for breaking up modules and inserting callbacks to allow
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 // individual functions to be compiled on demand.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 //
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 //===----------------------------------------------------------------------===//
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #define LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
18 #include "llvm/ADT/APInt.h"
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #include "llvm/ADT/STLExtras.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
20 #include "llvm/ADT/StringRef.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
21 #include "llvm/ADT/Twine.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
22 #include "llvm/ExecutionEngine/JITSymbol.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
23 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
24 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
25 #include "llvm/ExecutionEngine/Orc/OrcError.h"
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
26 #include "llvm/ExecutionEngine/RuntimeDyld.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
27 #include "llvm/IR/Attributes.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
28 #include "llvm/IR/Constant.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
29 #include "llvm/IR/Constants.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
30 #include "llvm/IR/DataLayout.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
31 #include "llvm/IR/Function.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
32 #include "llvm/IR/GlobalAlias.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
33 #include "llvm/IR/GlobalValue.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
34 #include "llvm/IR/GlobalVariable.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
35 #include "llvm/IR/Instruction.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
36 #include "llvm/IR/Mangler.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
37 #include "llvm/IR/Module.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
38 #include "llvm/IR/Type.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
39 #include "llvm/Support/Casting.h"
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
40 #include "llvm/Support/raw_ostream.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
41 #include "llvm/Transforms/Utils/ValueMapper.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
42 #include <algorithm>
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
43 #include <cassert>
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
44 #include <functional>
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
45 #include <iterator>
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 #include <list>
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
47 #include <memory>
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
48 #include <set>
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
49 #include <string>
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
50 #include <utility>
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
51 #include <vector>
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 namespace llvm {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
54
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
55 class Value;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
56
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
57 namespace orc {
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 /// @brief Compile-on-demand layer.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 ///
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
61 /// When a module is added to this layer a stub is created for each of its
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
62 /// function definitions. The stubs and other global values are immediately
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
63 /// added to the layer below. When a stub is called it triggers the extraction
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
64 /// of the function body from the original module. The extracted body is then
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
65 /// compiled and executed.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
66 template <typename BaseLayerT,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
67 typename CompileCallbackMgrT = JITCompileCallbackManager,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
68 typename IndirectStubsMgrT = IndirectStubsManager>
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 class CompileOnDemandLayer {
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
70 private:
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
71 template <typename MaterializerFtor>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
72 class LambdaMaterializer final : public ValueMaterializer {
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 public:
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
74 LambdaMaterializer(MaterializerFtor M) : M(std::move(M)) {}
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
75
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
76 Value *materialize(Value *V) final { return M(V); }
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 private:
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
79 MaterializerFtor M;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
80 };
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
82 template <typename MaterializerFtor>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
83 LambdaMaterializer<MaterializerFtor>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
84 createLambdaMaterializer(MaterializerFtor M) {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
85 return LambdaMaterializer<MaterializerFtor>(std::move(M));
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
86 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
87
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
88 using BaseLayerModuleHandleT = typename BaseLayerT::ModuleHandleT;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
90 // Provide type-erasure for the Modules and MemoryManagers.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
91 template <typename ResourceT>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
92 class ResourceOwner {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
93 public:
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
94 ResourceOwner() = default;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
95 ResourceOwner(const ResourceOwner &) = delete;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
96 ResourceOwner &operator=(const ResourceOwner &) = delete;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
97 virtual ~ResourceOwner() = default;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
98
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
99 virtual ResourceT& getResource() const = 0;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
100 };
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
101
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
102 template <typename ResourceT, typename ResourcePtrT>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
103 class ResourceOwnerImpl : public ResourceOwner<ResourceT> {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
104 public:
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
105 ResourceOwnerImpl(ResourcePtrT ResourcePtr)
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
106 : ResourcePtr(std::move(ResourcePtr)) {}
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
107
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
108 ResourceT& getResource() const override { return *ResourcePtr; }
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
109
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
110 private:
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
111 ResourcePtrT ResourcePtr;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
112 };
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
113
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
114 template <typename ResourceT, typename ResourcePtrT>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
115 std::unique_ptr<ResourceOwner<ResourceT>>
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
116 wrapOwnership(ResourcePtrT ResourcePtr) {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
117 using RO = ResourceOwnerImpl<ResourceT, ResourcePtrT>;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
118 return llvm::make_unique<RO>(std::move(ResourcePtr));
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
119 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
120
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
121 class StaticGlobalRenamer {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
122 public:
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
123 StaticGlobalRenamer() = default;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
124 StaticGlobalRenamer(StaticGlobalRenamer &&) = default;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
125 StaticGlobalRenamer &operator=(StaticGlobalRenamer &&) = default;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
126
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
127 void rename(Module &M) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
128 for (auto &F : M)
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
129 if (F.hasLocalLinkage())
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
130 F.setName("$static." + Twine(NextId++));
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
131 for (auto &G : M.globals())
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
132 if (G.hasLocalLinkage())
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
133 G.setName("$static." + Twine(NextId++));
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
134 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
135
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
136 private:
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
137 unsigned NextId = 0;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 };
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
140 struct LogicalDylib {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
141 using SymbolResolverFtor = std::function<JITSymbol(const std::string&)>;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
142
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
143 struct SourceModuleEntry {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
144 std::shared_ptr<Module> SourceMod;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
145 std::set<Function*> StubsToClone;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
146 };
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
147
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
148 using SourceModulesList = std::vector<SourceModuleEntry>;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
149 using SourceModuleHandle = typename SourceModulesList::size_type;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
150
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
151 SourceModuleHandle
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
152 addSourceModule(std::shared_ptr<Module> M) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
153 SourceModuleHandle H = SourceModules.size();
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
154 SourceModules.push_back(SourceModuleEntry());
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
155 SourceModules.back().SourceMod = std::move(M);
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
156 return H;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
157 }
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
158
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
159 Module& getSourceModule(SourceModuleHandle H) {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
160 return *SourceModules[H].SourceMod;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
161 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
162
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
163 std::set<Function*>& getStubsToClone(SourceModuleHandle H) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
164 return SourceModules[H].StubsToClone;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
165 }
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
166
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
167 JITSymbol findSymbol(BaseLayerT &BaseLayer, const std::string &Name,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
168 bool ExportedSymbolsOnly) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
169 if (auto Sym = StubsMgr->findStub(Name, ExportedSymbolsOnly))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
170 return Sym;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
171 for (auto BLH : BaseLayerHandles)
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
172 if (auto Sym = BaseLayer.findSymbolIn(BLH, Name, ExportedSymbolsOnly))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
173 return Sym;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
174 else if (auto Err = Sym.takeError())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
175 return std::move(Err);
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
176 return nullptr;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
177 }
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
178
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
179 Error removeModulesFromBaseLayer(BaseLayerT &BaseLayer) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
180 for (auto &BLH : BaseLayerHandles)
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
181 if (auto Err = BaseLayer.removeModule(BLH))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
182 return Err;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
183 return Error::success();
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
184 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
185
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
186 std::shared_ptr<JITSymbolResolver> ExternalSymbolResolver;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
187 std::unique_ptr<IndirectStubsMgrT> StubsMgr;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
188 StaticGlobalRenamer StaticRenamer;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
189 SourceModulesList SourceModules;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
190 std::vector<BaseLayerModuleHandleT> BaseLayerHandles;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 };
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
193 using LogicalDylibList = std::list<LogicalDylib>;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 public:
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
196
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
197 /// @brief Handle to loaded module.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
198 using ModuleHandleT = typename LogicalDylibList::iterator;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
200 /// @brief Module partitioning functor.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
201 using PartitioningFtor = std::function<std::set<Function*>(Function&)>;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
202
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
203 /// @brief Builder for IndirectStubsManagers.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
204 using IndirectStubsManagerBuilderT =
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
205 std::function<std::unique_ptr<IndirectStubsMgrT>()>;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
206
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 /// @brief Construct a compile-on-demand layer instance.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
208 CompileOnDemandLayer(BaseLayerT &BaseLayer, PartitioningFtor Partition,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
209 CompileCallbackMgrT &CallbackMgr,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
210 IndirectStubsManagerBuilderT CreateIndirectStubsManager,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
211 bool CloneStubsIntoPartitions = true)
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
212 : BaseLayer(BaseLayer), Partition(std::move(Partition)),
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
213 CompileCallbackMgr(CallbackMgr),
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
214 CreateIndirectStubsManager(std::move(CreateIndirectStubsManager)),
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
215 CloneStubsIntoPartitions(CloneStubsIntoPartitions) {}
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
217 ~CompileOnDemandLayer() {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
218 // FIXME: Report error on log.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
219 while (!LogicalDylibs.empty())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
220 consumeError(removeModule(LogicalDylibs.begin()));
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
221 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
222
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 /// @brief Add a module to the compile-on-demand layer.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
224 Expected<ModuleHandleT>
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
225 addModule(std::shared_ptr<Module> M,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
226 std::shared_ptr<JITSymbolResolver> Resolver) {
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
228 LogicalDylibs.push_back(LogicalDylib());
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
229 auto &LD = LogicalDylibs.back();
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
230 LD.ExternalSymbolResolver = std::move(Resolver);
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
231 LD.StubsMgr = CreateIndirectStubsManager();
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 // Process each of the modules in this module set.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
234 if (auto Err = addLogicalModule(LD, std::move(M)))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
235 return std::move(Err);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
237 return std::prev(LogicalDylibs.end());
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
240 /// @brief Add extra modules to an existing logical module.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
241 Error addExtraModule(ModuleHandleT H, std::shared_ptr<Module> M) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
242 return addLogicalModule(*H, std::move(M));
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
243 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
244
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 /// @brief Remove the module represented by the given handle.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 ///
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 /// This will remove all modules in the layers below that were derived from
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 /// the module represented by H.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
249 Error removeModule(ModuleHandleT H) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
250 auto Err = H->removeModulesFromBaseLayer(BaseLayer);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
251 LogicalDylibs.erase(H);
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
252 return Err;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 /// @brief Search for the given named symbol.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 /// @param Name The name of the symbol to search for.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 /// @param ExportedSymbolsOnly If true, search only for exported symbols.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 /// @return A handle for the given named symbol, if it exists.
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly) {
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
260 for (auto LDI = LogicalDylibs.begin(), LDE = LogicalDylibs.end();
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
261 LDI != LDE; ++LDI) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
262 if (auto Sym = LDI->StubsMgr->findStub(Name, ExportedSymbolsOnly))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
263 return Sym;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
264 if (auto Sym = findSymbolIn(LDI, Name, ExportedSymbolsOnly))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
265 return Sym;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
266 else if (auto Err = Sym.takeError())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
267 return std::move(Err);
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
268 }
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 /// @brief Get the address of a symbol provided by this layer, or some layer
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 /// below this one.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
274 JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 bool ExportedSymbolsOnly) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
276 return H->findSymbol(BaseLayer, Name, ExportedSymbolsOnly);
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
277 }
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
278
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
279 /// @brief Update the stub for the given function to point at FnBodyAddr.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
280 /// This can be used to support re-optimization.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
281 /// @return true if the function exists and the stub is updated, false
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
282 /// otherwise.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
283 //
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
284 // FIXME: We should track and free associated resources (unused compile
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
285 // callbacks, uncompiled IR, and no-longer-needed/reachable function
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
286 // implementations).
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
287 Error updatePointer(std::string FuncName, JITTargetAddress FnBodyAddr) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
288 //Find out which logical dylib contains our symbol
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
289 auto LDI = LogicalDylibs.begin();
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
290 for (auto LDE = LogicalDylibs.end(); LDI != LDE; ++LDI) {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
291 if (auto LMResources =
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
292 LDI->getLogicalModuleResourcesForSymbol(FuncName, false)) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
293 Module &SrcM = LMResources->SourceModule->getResource();
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
294 std::string CalledFnName = mangle(FuncName, SrcM.getDataLayout());
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
295 if (auto Err = LMResources->StubsMgr->updatePointer(CalledFnName,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
296 FnBodyAddr))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
297 return Err;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
298 return Error::success();
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
299 }
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
300 }
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
301 return make_error<JITSymbolNotFound>(FuncName);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 private:
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
305
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
306 Error addLogicalModule(LogicalDylib &LD, std::shared_ptr<Module> SrcMPtr) {
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
308 // Rename all static functions / globals to $static.X :
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
309 // This will unique the names across all modules in the logical dylib,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
310 // simplifying symbol lookup.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
311 LD.StaticRenamer.rename(*SrcMPtr);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
313 // Bump the linkage and rename any anonymous/privote members in SrcM to
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
314 // ensure that everything will resolve properly after we partition SrcM.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
315 makeAllSymbolsExternallyAccessible(*SrcMPtr);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
316
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
317 // Create a logical module handle for SrcM within the logical dylib.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
318 Module &SrcM = *SrcMPtr;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
319 auto LMId = LD.addSourceModule(std::move(SrcMPtr));
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
321 // Create stub functions.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
322 const DataLayout &DL = SrcM.getDataLayout();
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
323 {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
324 typename IndirectStubsMgrT::StubInitsMap StubInits;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
325 for (auto &F : SrcM) {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
326 // Skip declarations.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
327 if (F.isDeclaration())
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
328 continue;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
330 // Skip weak functions for which we already have definitions.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
331 auto MangledName = mangle(F.getName(), DL);
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
332 if (F.hasWeakLinkage() || F.hasLinkOnceLinkage()) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
333 if (auto Sym = LD.findSymbol(BaseLayer, MangledName, false))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
334 continue;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
335 else if (auto Err = Sym.takeError())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
336 return std::move(Err);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
337 }
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
338
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
339 // Record all functions defined by this module.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
340 if (CloneStubsIntoPartitions)
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
341 LD.getStubsToClone(LMId).insert(&F);
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
342
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
343 // Create a callback, associate it with the stub for the function,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
344 // and set the compile action to compile the partition containing the
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
345 // function.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
346 if (auto CCInfoOrErr = CompileCallbackMgr.getCompileCallback()) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
347 auto &CCInfo = *CCInfoOrErr;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
348 StubInits[MangledName] =
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
349 std::make_pair(CCInfo.getAddress(),
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
350 JITSymbolFlags::fromGlobalValue(F));
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
351 CCInfo.setCompileAction([this, &LD, LMId, &F]() -> JITTargetAddress {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
352 if (auto FnImplAddrOrErr = this->extractAndCompile(LD, LMId, F))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
353 return *FnImplAddrOrErr;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
354 else {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
355 // FIXME: Report error, return to 'abort' or something similar.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
356 consumeError(FnImplAddrOrErr.takeError());
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
357 return 0;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
358 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
359 });
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
360 } else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
361 return CCInfoOrErr.takeError();
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
362 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
363
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
364 if (auto Err = LD.StubsMgr->createStubs(StubInits))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
365 return Err;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
368 // If this module doesn't contain any globals, aliases, or module flags then
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
369 // we can bail out early and avoid the overhead of creating and managing an
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
370 // empty globals module.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
371 if (SrcM.global_empty() && SrcM.alias_empty() &&
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
372 !SrcM.getModuleFlagsMetadata())
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
373 return Error::success();
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
374
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
375 // Create the GlobalValues module.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
376 auto GVsM = llvm::make_unique<Module>((SrcM.getName() + ".globals").str(),
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
377 SrcM.getContext());
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
378 GVsM->setDataLayout(DL);
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
379
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
380 ValueToValueMapTy VMap;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
381
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
382 // Clone global variable decls.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
383 for (auto &GV : SrcM.globals())
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
384 if (!GV.isDeclaration() && !VMap.count(&GV))
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
385 cloneGlobalVariableDecl(*GVsM, GV, &VMap);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
387 // And the aliases.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
388 for (auto &A : SrcM.aliases())
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
389 if (!VMap.count(&A))
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
390 cloneGlobalAliasDecl(*GVsM, A, VMap);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
391
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
392 // Clone the module flags.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
393 cloneModuleFlagsMetadata(*GVsM, SrcM, VMap);
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
394
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
395 // Now we need to clone the GV and alias initializers.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
396
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
397 // Initializers may refer to functions declared (but not defined) in this
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
398 // module. Build a materializer to clone decls on demand.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
399 Error MaterializerErrors = Error::success();
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
400 auto Materializer = createLambdaMaterializer(
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
401 [&LD, &GVsM, &MaterializerErrors](Value *V) -> Value* {
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
402 if (auto *F = dyn_cast<Function>(V)) {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
403 // Decls in the original module just get cloned.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
404 if (F->isDeclaration())
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
405 return cloneFunctionDecl(*GVsM, *F);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
407 // Definitions in the original module (which we have emitted stubs
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
408 // for at this point) get turned into a constant alias to the stub
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
409 // instead.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
410 const DataLayout &DL = GVsM->getDataLayout();
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
411 std::string FName = mangle(F->getName(), DL);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
412 unsigned PtrBitWidth = DL.getPointerTypeSizeInBits(F->getType());
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
413 JITTargetAddress StubAddr = 0;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
414
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
415 // Get the address for the stub. If we encounter an error while
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
416 // doing so, stash it in the MaterializerErrors variable and use a
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
417 // null address as a placeholder.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
418 if (auto StubSym = LD.StubsMgr->findStub(FName, false)) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
419 if (auto StubAddrOrErr = StubSym.getAddress())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
420 StubAddr = *StubAddrOrErr;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
421 else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
422 MaterializerErrors = joinErrors(std::move(MaterializerErrors),
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
423 StubAddrOrErr.takeError());
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
424 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
425
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
426 ConstantInt *StubAddrCI =
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
427 ConstantInt::get(GVsM->getContext(), APInt(PtrBitWidth, StubAddr));
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
428 Constant *Init = ConstantExpr::getCast(Instruction::IntToPtr,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
429 StubAddrCI, F->getType());
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
430 return GlobalAlias::create(F->getFunctionType(),
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
431 F->getType()->getAddressSpace(),
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
432 F->getLinkage(), F->getName(),
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
433 Init, GVsM.get());
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
434 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
435 // else....
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
436 return nullptr;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
437 });
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
438
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
439 // Clone the global variable initializers.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
440 for (auto &GV : SrcM.globals())
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
441 if (!GV.isDeclaration())
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
442 moveGlobalVariableInitializer(GV, VMap, &Materializer);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
444 // Clone the global alias initializers.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
445 for (auto &A : SrcM.aliases()) {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
446 auto *NewA = cast<GlobalAlias>(VMap[&A]);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
447 assert(NewA && "Alias not cloned?");
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
448 Value *Init = MapValue(A.getAliasee(), VMap, RF_None, nullptr,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
449 &Materializer);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
450 NewA->setAliasee(cast<Constant>(Init));
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
451 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
452
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
453 if (MaterializerErrors)
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
454 return MaterializerErrors;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
455
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
456 // Build a resolver for the globals module and add it to the base layer.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
457 auto GVsResolver = createLambdaResolver(
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
458 [this, &LD](const std::string &Name) -> JITSymbol {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
459 if (auto Sym = LD.StubsMgr->findStub(Name, false))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
460 return Sym;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
461 if (auto Sym = LD.findSymbol(BaseLayer, Name, false))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
462 return Sym;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
463 else if (auto Err = Sym.takeError())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
464 return std::move(Err);
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
465 return LD.ExternalSymbolResolver->findSymbolInLogicalDylib(Name);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 },
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
467 [&LD](const std::string &Name) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
468 return LD.ExternalSymbolResolver->findSymbol(Name);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 });
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
471 if (auto GVsHOrErr =
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
472 BaseLayer.addModule(std::move(GVsM), std::move(GVsResolver)))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
473 LD.BaseLayerHandles.push_back(*GVsHOrErr);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
474 else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
475 return GVsHOrErr.takeError();
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
476
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
477 return Error::success();
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
480 static std::string mangle(StringRef Name, const DataLayout &DL) {
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 std::string MangledName;
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 {
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 raw_string_ostream MangledNameStream(MangledName);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
484 Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 return MangledName;
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 }
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
489 Expected<JITTargetAddress>
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
490 extractAndCompile(LogicalDylib &LD,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
491 typename LogicalDylib::SourceModuleHandle LMId,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
492 Function &F) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
493 Module &SrcM = LD.getSourceModule(LMId);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
494
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
495 // If F is a declaration we must already have compiled it.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
496 if (F.isDeclaration())
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
497 return 0;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
498
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
499 // Grab the name of the function being called here.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
500 std::string CalledFnName = mangle(F.getName(), SrcM.getDataLayout());
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
501
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
502 JITTargetAddress CalledAddr = 0;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
503 auto Part = Partition(F);
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
504 if (auto PartHOrErr = emitPartition(LD, LMId, Part)) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
505 auto &PartH = *PartHOrErr;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
506 for (auto *SubF : Part) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
507 std::string FnName = mangle(SubF->getName(), SrcM.getDataLayout());
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
508 if (auto FnBodySym = BaseLayer.findSymbolIn(PartH, FnName, false)) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
509 if (auto FnBodyAddrOrErr = FnBodySym.getAddress()) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
510 JITTargetAddress FnBodyAddr = *FnBodyAddrOrErr;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
511
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
512 // If this is the function we're calling record the address so we can
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
513 // return it from this function.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
514 if (SubF == &F)
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
515 CalledAddr = FnBodyAddr;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
516
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
517 // Update the function body pointer for the stub.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
518 if (auto EC = LD.StubsMgr->updatePointer(FnName, FnBodyAddr))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
519 return 0;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
520
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
521 } else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
522 return FnBodyAddrOrErr.takeError();
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
523 } else if (auto Err = FnBodySym.takeError())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
524 return std::move(Err);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
525 else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
526 llvm_unreachable("Function not emitted for partition");
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
527 }
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
528
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
529 LD.BaseLayerHandles.push_back(PartH);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
530 } else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
531 return PartHOrErr.takeError();
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
532
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
533 return CalledAddr;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
534 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
535
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
536 template <typename PartitionT>
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
537 Expected<BaseLayerModuleHandleT>
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
538 emitPartition(LogicalDylib &LD,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
539 typename LogicalDylib::SourceModuleHandle LMId,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
540 const PartitionT &Part) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
541 Module &SrcM = LD.getSourceModule(LMId);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
542
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
543 // Create the module.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
544 std::string NewName = SrcM.getName();
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
545 for (auto *F : Part) {
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
546 NewName += ".";
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
547 NewName += F->getName();
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
548 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
549
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
550 auto M = llvm::make_unique<Module>(NewName, SrcM.getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
551 M->setDataLayout(SrcM.getDataLayout());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
552 ValueToValueMapTy VMap;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
553
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
554 auto Materializer = createLambdaMaterializer([&LD, &LMId,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
555 &M](Value *V) -> Value * {
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
556 if (auto *GV = dyn_cast<GlobalVariable>(V))
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
557 return cloneGlobalVariableDecl(*M, *GV);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
558
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
559 if (auto *F = dyn_cast<Function>(V)) {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
560 // Check whether we want to clone an available_externally definition.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
561 if (!LD.getStubsToClone(LMId).count(F))
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
562 return cloneFunctionDecl(*M, *F);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
563
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
564 // Ok - we want an inlinable stub. For that to work we need a decl
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
565 // for the stub pointer.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
566 auto *StubPtr = createImplPointer(*F->getType(), *M,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
567 F->getName() + "$stub_ptr", nullptr);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
568 auto *ClonedF = cloneFunctionDecl(*M, *F);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
569 makeStub(*ClonedF, *StubPtr);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
570 ClonedF->setLinkage(GlobalValue::AvailableExternallyLinkage);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
571 ClonedF->addFnAttr(Attribute::AlwaysInline);
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
572 return ClonedF;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
573 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
574
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
575 if (auto *A = dyn_cast<GlobalAlias>(V)) {
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
576 auto *Ty = A->getValueType();
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
577 if (Ty->isFunctionTy())
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
578 return Function::Create(cast<FunctionType>(Ty),
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
579 GlobalValue::ExternalLinkage, A->getName(),
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
580 M.get());
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
581
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
582 return new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
583 nullptr, A->getName(), nullptr,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
584 GlobalValue::NotThreadLocal,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
585 A->getType()->getAddressSpace());
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
586 }
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
587
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
588 return nullptr;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
589 });
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
590
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
591 // Create decls in the new module.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
592 for (auto *F : Part)
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
593 cloneFunctionDecl(*M, *F, &VMap);
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
594
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
595 // Move the function bodies.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
596 for (auto *F : Part)
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
597 moveFunctionBody(*F, VMap, &Materializer);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
598
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
599 // Create memory manager and symbol resolver.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
600 auto Resolver = createLambdaResolver(
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
601 [this, &LD](const std::string &Name) -> JITSymbol {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
602 if (auto Sym = LD.findSymbol(BaseLayer, Name, false))
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
603 return Sym;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
604 else if (auto Err = Sym.takeError())
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
605 return std::move(Err);
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
606 return LD.ExternalSymbolResolver->findSymbolInLogicalDylib(Name);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
607 },
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
608 [&LD](const std::string &Name) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
609 return LD.ExternalSymbolResolver->findSymbol(Name);
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
610 });
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
611
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
612 return BaseLayer.addModule(std::move(M), std::move(Resolver));
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
613 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
614
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 BaseLayerT &BaseLayer;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
616 PartitioningFtor Partition;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
617 CompileCallbackMgrT &CompileCallbackMgr;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
618 IndirectStubsManagerBuilderT CreateIndirectStubsManager;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
619
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
620 LogicalDylibList LogicalDylibs;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
621 bool CloneStubsIntoPartitions;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 };
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
623
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
624 } // end namespace orc
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
625
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
626 } // end namespace llvm
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H