LLVM: lib/ExecutionEngine/Orc/ThreadSafeModule.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
13
14namespace llvm {
15namespace orc {
16
17static std::pair<std::string, SmallVector<char, 1>>
22
24 std::set<GlobalValue *> ClonedDefsInSrc;
27 if (ShouldCloneDef(*GV)) {
28 ClonedDefsInSrc.insert(const_cast<GlobalValue *>(GV));
29 return true;
30 }
31 return false;
32 });
33
34 if (UpdateClonedDefSource)
35 for (auto *GV : ClonedDefsInSrc)
36 UpdateClonedDefSource(*GV);
37
42
43 return {std::move(ModuleName), std::move(ClonedModuleBuffer)};
44}
45
46ThreadSafeModule
52 "cloned module buffer");
53
54
56 assert(Ctx && "No LLVMContext provided");
58 TmpM->setModuleIdentifier(ModuleName);
59 return TmpM;
60 });
61
63}
64
65ThreadSafeModule
69
70 if (!ShouldCloneDef)
71 ShouldCloneDef = [](const GlobalValue &) { return true; };
72
74 M, std::move(ShouldCloneDef), std::move(UpdateClonedDefSource));
75
77 std::move(TSCtx));
78}
79
84 assert(TSM && "Can not clone null module");
85
86 if (!ShouldCloneDef)
87 ShouldCloneDef = [](const GlobalValue &) { return true; };
88
89
92 std::move(UpdateClonedDefSource));
93 });
94
96 std::move(TSCtx));
97}
98
102 assert(TSM && "Can not clone null module");
103
105 return cloneToContext(TSM, std::move(TSCtx), std::move(ShouldCloneDef),
106 std::move(UpdateClonedDefSource));
107}
108
109}
110}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
LLVM_ABI void writeStrtab()
Write the bitcode file's string table.
LLVM_ABI void writeSymtab()
Attempt to write a symbol table to the bitcode file.
LLVM_ABI void writeModule(const Module &M, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the buffer specified at construction time.
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
An LLVMContext together with an associated mutex that can be used to lock the context to prevent conc...
decltype(auto) withContextDo(Func &&F)
An LLVM Module together with a shared ThreadSafeContext.
decltype(auto) withModuleDo(Func &&F)
Locks the associated ThreadSafeContext and calls the given function on the contained Module.
ThreadSafeModule deserializeModule(std::string ModuleName, const SmallVector< char, 1 > &ClonedModuleBuffer, ThreadSafeContext TSCtx)
Definition ThreadSafeModule.cpp:47
std::function< bool(const GlobalValue &)> GVPredicate
std::function< void(GlobalValue &)> GVModifier
LLVM_ABI ThreadSafeModule cloneToContext(const ThreadSafeModule &TSMW, ThreadSafeContext TSCtx, GVPredicate ShouldCloneDef=GVPredicate(), GVModifier UpdateClonedDefSource=GVModifier())
Clones the given module onto the given context.
Definition ThreadSafeModule.cpp:80
static std::pair< std::string, SmallVector< char, 1 > > serializeModule(const Module &M, GVPredicate ShouldCloneDef, GVModifier UpdateClonedDefSource)
Definition ThreadSafeModule.cpp:18
LLVM_ABI ThreadSafeModule cloneExternalModuleToContext(const Module &M, ThreadSafeContext TSCtx, GVPredicate ShouldCloneDef=GVPredicate(), GVModifier UpdateClonedDefSource=GVModifier())
Clone the given module onto the given context.
Definition ThreadSafeModule.cpp:66
LLVM_ABI ThreadSafeModule cloneToNewContext(const ThreadSafeModule &TSMW, GVPredicate ShouldCloneDef=GVPredicate(), GVModifier UpdateClonedDefSource=GVModifier())
Clones the given module on to a new context.
Definition ThreadSafeModule.cpp:99
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context, ParserCallbacks Callbacks={})
Read the specified bitcode file, returning the module.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
LLVM_ABI std::unique_ptr< Module > CloneModule(const Module &M)
Return an exact copy of the specified module.