17static std::pair<std::string, SmallVector<char, 1>>
24 std::set<GlobalValue *> ClonedDefsInSrc;
27 if (ShouldCloneDef(*GV)) {
34 if (UpdateClonedDefSource)
35 for (
auto *GV : ClonedDefsInSrc)
36 UpdateClonedDefSource(*GV);
43 return {std::move(
ModuleName), std::move(ClonedModuleBuffer)};
52 "cloned module buffer");
56 assert(Ctx &&
"No LLVMContext provided");
71 ShouldCloneDef = [](
const GlobalValue &) {
return true; };
74 M, std::move(ShouldCloneDef), std::move(UpdateClonedDefSource));
84 assert(TSM &&
"Can not clone null module");
87 ShouldCloneDef = [](
const GlobalValue &) {
return true; };
92 std::move(UpdateClonedDefSource));
102 assert(TSM &&
"Can not clone null module");
105 return cloneToContext(TSM, std::move(TSCtx), std::move(ShouldCloneDef),
106 std::move(UpdateClonedDefSource));
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.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
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)
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.
static std::pair< std::string, SmallVector< char, 1 > > serializeModule(const Module &M, GVPredicate ShouldCloneDef, GVModifier UpdateClonedDefSource)
LLVM_ABI ThreadSafeModule cloneExternalModuleToContext(const Module &M, ThreadSafeContext TSCtx, GVPredicate ShouldCloneDef=GVPredicate(), GVModifier UpdateClonedDefSource=GVModifier())
Clone the given module onto the given context.
LLVM_ABI ThreadSafeModule cloneToNewContext(const ThreadSafeModule &TSMW, GVPredicate ShouldCloneDef=GVPredicate(), GVModifier UpdateClonedDefSource=GVModifier())
Clones the given module on to a new context.
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.
LLVM_ABI std::unique_ptr< Module > CloneModule(const Module &M)
Return an exact copy of the specified module.