LLVM 17.0.0git
IndirectionUtils.cpp
Go to the documentation of this file.
1//===---- IndirectionUtils.cpp - Utilities for call indirection in Orc ----===//
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
10#include "llvm/ADT/STLExtras.h"
13#include "llvm/IR/IRBuilder.h"
16#include "llvm/Support/Format.h"
19#include <sstream>
20
21#define DEBUG_TYPE "orc"
22
23using namespace llvm;
24using namespace llvm::orc;
25
26namespace {
27
28class CompileCallbackMaterializationUnit : public orc::MaterializationUnit {
29public:
30 using CompileFunction = JITCompileCallbackManager::CompileFunction;
31
32 CompileCallbackMaterializationUnit(SymbolStringPtr Name,
33 CompileFunction Compile)
34 : MaterializationUnit(Interface(
36 Name(std::move(Name)), Compile(std::move(Compile)) {}
37
38 StringRef getName() const override { return "<Compile Callbacks>"; }
39
40private:
41 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
44 // No dependencies, so these calls cannot fail.
45 cantFail(R->notifyResolved(Result));
46 cantFail(R->notifyEmitted());
47 }
48
49 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override {
50 llvm_unreachable("Discard should never occur on a LMU?");
51 }
52
54 CompileFunction Compile;
55};
56
57} // namespace
58
59namespace llvm {
60namespace orc {
61
63void IndirectStubsManager::anchor() {}
64
67 if (auto TrampolineAddr = TP->getTrampoline()) {
68 auto CallbackName =
69 ES.intern(std::string("cc") + std::to_string(++NextCallbackId));
70
71 std::lock_guard<std::mutex> Lock(CCMgrMutex);
72 AddrToSymbol[*TrampolineAddr] = CallbackName;
74 CallbacksJD.define(std::make_unique<CompileCallbackMaterializationUnit>(
75 std::move(CallbackName), std::move(Compile))));
76 return *TrampolineAddr;
77 } else
78 return TrampolineAddr.takeError();
79}
80
82 JITTargetAddress TrampolineAddr) {
84
85 {
86 std::unique_lock<std::mutex> Lock(CCMgrMutex);
87 auto I = AddrToSymbol.find(TrampolineAddr);
88
89 // If this address is not associated with a compile callback then report an
90 // error to the execution session and return ErrorHandlerAddress to the
91 // callee.
92 if (I == AddrToSymbol.end()) {
93 Lock.unlock();
94 std::string ErrMsg;
95 {
96 raw_string_ostream ErrMsgStream(ErrMsg);
97 ErrMsgStream << "No compile callback for trampoline at "
98 << format("0x%016" PRIx64, TrampolineAddr);
99 }
100 ES.reportError(
101 make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode()));
102 return ErrorHandlerAddress;
103 } else
104 Name = I->second;
105 }
106
107 if (auto Sym =
110 Name))
111 return Sym->getAddress();
112 else {
113 llvm::dbgs() << "Didn't find callback.\n";
114 // If anything goes wrong materializing Sym then report it to the session
115 // and return the ErrorHandlerAddress;
116 ES.reportError(Sym.takeError());
117 return ErrorHandlerAddress;
118 }
119}
120
123 JITTargetAddress ErrorHandlerAddress) {
124 switch (T.getArch()) {
125 default:
126 return make_error<StringError>(
127 std::string("No callback manager available for ") + T.str(),
129 case Triple::aarch64:
130 case Triple::aarch64_32: {
132 return CCMgrT::Create(ES, ErrorHandlerAddress);
133 }
134
135 case Triple::x86: {
137 return CCMgrT::Create(ES, ErrorHandlerAddress);
138 }
139
140 case Triple::loongarch64: {
142 return CCMgrT::Create(ES, ErrorHandlerAddress);
143 }
144
145 case Triple::mips: {
147 return CCMgrT::Create(ES, ErrorHandlerAddress);
148 }
149 case Triple::mipsel: {
151 return CCMgrT::Create(ES, ErrorHandlerAddress);
152 }
153
154 case Triple::mips64:
155 case Triple::mips64el: {
157 return CCMgrT::Create(ES, ErrorHandlerAddress);
158 }
159
160 case Triple::riscv64: {
162 return CCMgrT::Create(ES, ErrorHandlerAddress);
163 }
164
165 case Triple::x86_64: {
166 if (T.getOS() == Triple::OSType::Win32) {
168 return CCMgrT::Create(ES, ErrorHandlerAddress);
169 } else {
171 return CCMgrT::Create(ES, ErrorHandlerAddress);
172 }
173 }
174
175 }
176}
177
178std::function<std::unique_ptr<IndirectStubsManager>()>
180 switch (T.getArch()) {
181 default:
182 return [](){
183 return std::make_unique<
185 };
186
187 case Triple::aarch64:
189 return [](){
190 return std::make_unique<
192 };
193
194 case Triple::x86:
195 return [](){
196 return std::make_unique<
198 };
199
201 return []() {
202 return std::make_unique<
204 };
205
206 case Triple::mips:
207 return [](){
208 return std::make_unique<
210 };
211
212 case Triple::mipsel:
213 return [](){
214 return std::make_unique<
216 };
217
218 case Triple::mips64:
219 case Triple::mips64el:
220 return [](){
221 return std::make_unique<
223 };
224
225 case Triple::riscv64:
226 return []() {
227 return std::make_unique<
229 };
230
231 case Triple::x86_64:
232 if (T.getOS() == Triple::OSType::Win32) {
233 return [](){
234 return std::make_unique<
236 };
237 } else {
238 return [](){
239 return std::make_unique<
241 };
242 }
243
244 }
245}
246
248 Constant *AddrIntVal =
250 Constant *AddrPtrVal =
251 ConstantExpr::getCast(Instruction::IntToPtr, AddrIntVal,
252 PointerType::get(&FT, 0));
253 return AddrPtrVal;
254}
255
257 const Twine &Name, Constant *Initializer) {
258 auto IP = new GlobalVariable(M, &PT, false, GlobalValue::ExternalLinkage,
259 Initializer, Name, nullptr,
261 IP->setVisibility(GlobalValue::HiddenVisibility);
262 return IP;
263}
264
265void makeStub(Function &F, Value &ImplPointer) {
266 assert(F.isDeclaration() && "Can't turn a definition into a stub.");
267 assert(F.getParent() && "Function isn't in a module.");
268 Module &M = *F.getParent();
269 BasicBlock *EntryBlock = BasicBlock::Create(M.getContext(), "entry", &F);
270 IRBuilder<> Builder(EntryBlock);
271 LoadInst *ImplAddr = Builder.CreateLoad(F.getType(), &ImplPointer);
272 std::vector<Value*> CallArgs;
273 for (auto &A : F.args())
274 CallArgs.push_back(&A);
275 CallInst *Call = Builder.CreateCall(F.getFunctionType(), ImplAddr, CallArgs);
276 Call->setTailCall();
277 Call->setAttributes(F.getAttributes());
278 if (F.getReturnType()->isVoidTy())
279 Builder.CreateRetVoid();
280 else
281 Builder.CreateRet(Call);
282}
283
284std::vector<GlobalValue *> SymbolLinkagePromoter::operator()(Module &M) {
285 std::vector<GlobalValue *> PromotedGlobals;
286
287 for (auto &GV : M.global_values()) {
288 bool Promoted = true;
289
290 // Rename if necessary.
291 if (!GV.hasName())
292 GV.setName("__orc_anon." + Twine(NextId++));
293 else if (GV.getName().startswith("\01L"))
294 GV.setName("__" + GV.getName().substr(1) + "." + Twine(NextId++));
295 else if (GV.hasLocalLinkage())
296 GV.setName("__orc_lcl." + GV.getName() + "." + Twine(NextId++));
297 else
298 Promoted = false;
299
300 if (GV.hasLocalLinkage()) {
301 GV.setLinkage(GlobalValue::ExternalLinkage);
302 GV.setVisibility(GlobalValue::HiddenVisibility);
303 Promoted = true;
304 }
305 GV.setUnnamedAddr(GlobalValue::UnnamedAddr::None);
306
307 if (Promoted)
308 PromotedGlobals.push_back(&GV);
309 }
310
311 return PromotedGlobals;
312}
313
315 ValueToValueMapTy *VMap) {
316 Function *NewF =
317 Function::Create(cast<FunctionType>(F.getValueType()),
318 F.getLinkage(), F.getName(), &Dst);
319 NewF->copyAttributesFrom(&F);
320
321 if (VMap) {
322 (*VMap)[&F] = NewF;
323 auto NewArgI = NewF->arg_begin();
324 for (auto ArgI = F.arg_begin(), ArgE = F.arg_end(); ArgI != ArgE;
325 ++ArgI, ++NewArgI)
326 (*VMap)[&*ArgI] = &*NewArgI;
327 }
328
329 return NewF;
330}
331
333 ValueMaterializer *Materializer,
334 Function *NewF) {
335 assert(!OrigF.isDeclaration() && "Nothing to move");
336 if (!NewF)
337 NewF = cast<Function>(VMap[&OrigF]);
338 else
339 assert(VMap[&OrigF] == NewF && "Incorrect function mapping in VMap.");
340 assert(NewF && "Function mapping missing from VMap.");
341 assert(NewF->getParent() != OrigF.getParent() &&
342 "moveFunctionBody should only be used to move bodies between "
343 "modules.");
344
345 SmallVector<ReturnInst *, 8> Returns; // Ignore returns cloned.
346 CloneFunctionInto(NewF, &OrigF, VMap,
348 nullptr, nullptr, Materializer);
349 OrigF.deleteBody();
350}
351
353 ValueToValueMapTy *VMap) {
354 GlobalVariable *NewGV = new GlobalVariable(
355 Dst, GV.getValueType(), GV.isConstant(),
356 GV.getLinkage(), nullptr, GV.getName(), nullptr,
358 NewGV->copyAttributesFrom(&GV);
359 if (VMap)
360 (*VMap)[&GV] = NewGV;
361 return NewGV;
362}
363
365 ValueToValueMapTy &VMap,
366 ValueMaterializer *Materializer,
367 GlobalVariable *NewGV) {
368 assert(OrigGV.hasInitializer() && "Nothing to move");
369 if (!NewGV)
370 NewGV = cast<GlobalVariable>(VMap[&OrigGV]);
371 else
372 assert(VMap[&OrigGV] == NewGV &&
373 "Incorrect global variable mapping in VMap.");
374 assert(NewGV->getParent() != OrigGV.getParent() &&
375 "moveGlobalVariableInitializer should only be used to move "
376 "initializers between modules");
377
378 NewGV->setInitializer(MapValue(OrigGV.getInitializer(), VMap, RF_None,
379 nullptr, Materializer));
380}
381
383 ValueToValueMapTy &VMap) {
384 assert(OrigA.getAliasee() && "Original alias doesn't have an aliasee?");
385 auto *NewA = GlobalAlias::create(OrigA.getValueType(),
387 OrigA.getLinkage(), OrigA.getName(), &Dst);
388 NewA->copyAttributesFrom(&OrigA);
389 VMap[&OrigA] = NewA;
390 return NewA;
391}
392
394 ValueToValueMapTy &VMap) {
395 auto *MFs = Src.getModuleFlagsMetadata();
396 if (!MFs)
397 return;
398 for (auto *MF : MFs->operands())
399 Dst.addModuleFlag(MapMetadata(MF, VMap));
400}
401
404 MCDisassembler &Disassembler,
405 MCInstrAnalysis &MIA) {
406 // AArch64 appears to already come with the necessary relocations. Among other
407 // architectures, only x86_64 is currently implemented here.
408 if (G.getTargetTriple().getArch() != Triple::x86_64)
409 return Error::success();
410
411 raw_null_ostream CommentStream;
412 auto &STI = Disassembler.getSubtargetInfo();
413
414 // Determine the function bounds
415 auto &B = Sym.getBlock();
416 assert(!B.isZeroFill() && "expected content block");
417 auto SymAddress = Sym.getAddress();
418 auto SymStartInBlock =
419 (const uint8_t *)B.getContent().data() + Sym.getOffset();
420 auto SymSize = Sym.getSize() ? Sym.getSize() : B.getSize() - Sym.getOffset();
421 auto Content = ArrayRef(SymStartInBlock, SymSize);
422
423 LLVM_DEBUG(dbgs() << "Adding self-relocations to " << Sym.getName() << "\n");
424
425 SmallDenseSet<uintptr_t, 8> ExistingRelocations;
426 for (auto &E : B.edges()) {
427 if (E.isRelocation())
428 ExistingRelocations.insert(E.getOffset());
429 }
430
431 size_t I = 0;
432 while (I < Content.size()) {
433 MCInst Instr;
434 uint64_t InstrSize = 0;
435 uint64_t InstrStart = SymAddress.getValue() + I;
436 auto DecodeStatus = Disassembler.getInstruction(
437 Instr, InstrSize, Content.drop_front(I), InstrStart, CommentStream);
439 LLVM_DEBUG(dbgs() << "Aborting due to disassembly failure at address "
440 << InstrStart);
441 return make_error<StringError>(
442 formatv("failed to disassemble at address {0:x16}", InstrStart),
444 }
445 // Advance to the next instruction.
446 I += InstrSize;
447
448 // Check for a PC-relative address equal to the symbol itself.
449 auto PCRelAddr =
450 MIA.evaluateMemoryOperandAddress(Instr, &STI, InstrStart, InstrSize);
451 if (!PCRelAddr || *PCRelAddr != SymAddress.getValue())
452 continue;
453
454 auto RelocOffInInstr =
455 MIA.getMemoryOperandRelocationOffset(Instr, InstrSize);
456 if (!RelocOffInInstr || InstrSize - *RelocOffInInstr != 4) {
457 LLVM_DEBUG(dbgs() << "Skipping unknown self-relocation at "
458 << InstrStart);
459 continue;
460 }
461
462 auto RelocOffInBlock = orc::ExecutorAddr(InstrStart) + *RelocOffInInstr -
463 SymAddress + Sym.getOffset();
464 if (ExistingRelocations.contains(RelocOffInBlock))
465 continue;
466
467 LLVM_DEBUG(dbgs() << "Adding delta32 self-relocation at " << InstrStart);
468 B.addEdge(jitlink::x86_64::Delta32, RelocOffInBlock, Sym, /*Addend=*/-4);
469 }
470 return Error::success();
471}
472
473} // End namespace orc.
474} // End namespace llvm.
assume Assume Builder
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DEBUG(X)
Definition: Debug.h:101
T Content
uint64_t Addr
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:56
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:105
This class represents a function call, abstracting a target machine's calling convention.
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Definition: Constants.cpp:1964
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:888
This is an important base class in LLVM.
Definition: Constant.h:41
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
static ErrorSuccess success()
Create a success value.
Definition: Error.h:330
Tagged union holding either a T or a Error.
Definition: Error.h:470
Class to represent function types.
Definition: DerivedTypes.h:103
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external.
Definition: Function.h:664
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:136
arg_iterator arg_begin()
Definition: Function.h:771
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:743
const Constant * getAliasee() const
Definition: GlobalAlias.h:84
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:520
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:275
LinkageTypes getLinkage() const
Definition: GlobalValue.h:541
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:267
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:652
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:290
@ HiddenVisibility
The GV is hidden.
Definition: GlobalValue.h:64
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
Type * getValueType() const
Definition: GlobalValue.h:292
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Globals.cpp:472
bool hasInitializer() const
Definitions have initializers, declarations don't.
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
Definition: Globals.cpp:495
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2558
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
An instruction for reading from memory.
Definition: Instructions.h:177
Superclass for all disassemblers.
const MCSubtargetInfo & getSubtargetInfo() const
DecodeStatus
Ternary decode status.
virtual DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const =0
Returns the disassembly of a single instruction.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
virtual std::optional< uint64_t > getMemoryOperandRelocationOffset(const MCInst &Inst, uint64_t Size) const
Given an instruction with a memory operand that could require relocation, returns the offset within t...
virtual std::optional< uint64_t > evaluateMemoryOperandAddress(const MCInst &Inst, const MCSubtargetInfo *STI, uint64_t Addr, uint64_t Size) const
Given an instruction tries to get the address of a memory operand.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Class to represent pointers.
Definition: DerivedTypes.h:632
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:682
Implements a dense probed hash-table based set with some number of buckets stored inline.
Definition: DenseSet.h:290
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ loongarch64
Definition: Triple.h:62
@ mips64el
Definition: Triple.h:67
@ aarch64_32
Definition: Triple.h:53
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:129
static IntegerType * getInt64Ty(LLVMContext &C)
This is a class that can be implemented by clients to materialize Values on demand.
Definition: ValueMapper.h:49
LLVM Value Representation.
Definition: Value.h:74
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
Definition: DenseSet.h:185
An ExecutionSession represents a running JIT program.
Definition: Core.h:1373
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1496
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition: Core.h:1427
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Definition: Core.cpp:2084
Represents an address in the executor process.
std::function< JITTargetAddress()> CompileFunction
JITTargetAddress executeCompileCallback(JITTargetAddress TrampolineAddr)
Execute the callback for the given trampoline id.
Expected< JITTargetAddress > getCompileCallback(CompileFunction Compile)
Reserve a compile callback.
Represents a JIT'd dynamic library.
Definition: Core.h:962
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
Definition: Core.h:1816
IndirectStubsManager implementation for the host architecture, e.g.
Manage compile callbacks for in-process JITs.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Definition: Core.h:673
virtual StringRef getName() const =0
Return the name of this materialization unit.
virtual void materialize(std::unique_ptr< MaterializationResponsibility > R)=0
Implementations of this method should materialize all symbols in the materialzation unit,...
std::vector< GlobalValue * > operator()(Module &M)
Promote symbols in the given module.
Pointer to a pooled string representing a symbol name.
A raw_ostream that discards all output.
Definition: raw_ostream.h:705
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:642
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
Definition: Core.h:163
void moveGlobalVariableInitializer(GlobalVariable &OrigGV, ValueToValueMapTy &VMap, ValueMaterializer *Materializer=nullptr, GlobalVariable *NewGV=nullptr)
Move global variable GV from its parent module to cloned global declaration in a different module.
void cloneModuleFlagsMetadata(Module &Dst, const Module &Src, ValueToValueMapTy &VMap)
Clone module flags metadata into the destination module.
Expected< std::unique_ptr< JITCompileCallbackManager > > createLocalCompileCallbackManager(const Triple &T, ExecutionSession &ES, JITTargetAddress ErrorHandlerAddress)
Create a local compile callback manager.
void makeStub(Function &F, Value &ImplPointer)
Turn a function declaration into a stub function that makes an indirect call using the given function...
Error addFunctionPointerRelocationsToCurrentSymbol(jitlink::Symbol &Sym, jitlink::LinkGraph &G, MCDisassembler &Disassembler, MCInstrAnalysis &MIA)
Introduce relocations to Sym in its own definition if there are any pointers formed via PC-relative a...
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
Definition: Core.h:121
GlobalVariable * cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV, ValueToValueMapTy *VMap=nullptr)
Clone a global variable declaration into a new module.
Function * cloneFunctionDecl(Module &Dst, const Function &F, ValueToValueMapTy *VMap=nullptr)
Clone a function declaration into a new module.
void moveFunctionBody(Function &OrigF, ValueToValueMapTy &VMap, ValueMaterializer *Materializer=nullptr, Function *NewF=nullptr)
Move the body of function 'F' to a cloned function declaration in a different module (See related clo...
std::function< std::unique_ptr< IndirectStubsManager >()> createLocalIndirectStubsManagerBuilder(const Triple &T)
Create a local indriect stubs manager builder.
GlobalAlias * cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA, ValueToValueMapTy &VMap)
Clone a global alias declaration into a new module.
Constant * createIRTypedAddress(FunctionType &FT, JITTargetAddress Addr)
Build a function pointer of FunctionType with the given constant address.
GlobalVariable * createImplPointer(PointerType &PT, Module &M, const Twine &Name, Constant *Initializer)
Create a function pointer with the given type, name, and initializer in the given Module.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:79
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Definition: JITSymbol.h:42
Metadata * MapMetadata(const Metadata *MD, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Lookup or compute a mapping for a piece of metadata.
Definition: ValueMapper.h:233
@ RF_None
Definition: ValueMapper.h:66
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
Value * MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Look up or compute a value in the value map.
Definition: ValueMapper.h:211
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:745
void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, CloneFunctionChangeType Changes, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Clone OldFunc into NewFunc, transforming the old arguments into references to VMap values.