21 assert(TSM &&
"Can not clone null module");
24 ShouldCloneDef = [](
const GlobalValue &) {
return true; };
30 std::set<GlobalValue *> ClonedDefsInSrc;
33 if (ShouldCloneDef(*GV)) {
34 ClonedDefsInSrc.
insert(const_cast<GlobalValue *>(GV));
40 if (UpdateClonedDefSource)
41 for (
auto *GV : ClonedDefsInSrc)
42 UpdateClonedDefSource(*GV);
53 "cloned module buffer");
58 ClonedModule->setModuleIdentifier(M.
getName());
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
This class represents lattice values for constants.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
A Module instance is used to store all the information related to an LLVM module. ...
An LLVMContext together with an associated mutex that can be used to lock the context to prevent conc...
auto withModuleDo(Func &&F) -> decltype(F(std::declval< Module &>()))
Locks the associated ThreadSafeContext and calls the given function on the contained Module...
void writeSymtab()
Attempt to write a symbol table to the bitcode file.
StringRef getName() const
Get a short "name" for the module.
std::function< bool(const GlobalValue &)> GVPredicate
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.
std::unique_ptr< Module > CloneModule(const Module &M)
Return an exact copy of the specified module.
LLVMContext * getContext()
Returns a pointer to the LLVMContext that was used to construct this instance, or null if the instanc...
An LLVM Module together with a shared ThreadSafeContext.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context)
Read the specified bitcode file, returning the module.
pointer data()
Return a pointer to the vector's buffer, even if empty().
ThreadSafeModule cloneToNewContext(ThreadSafeModule &TSMW, GVPredicate ShouldCloneDef=GVPredicate(), GVModifier UpdateClonedDefSource=GVModifier())
Clones the given module on to a new context.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::function< void(GlobalValue &)> GVModifier
StringRef - Represent a constant reference to a string, i.e.
void writeStrtab()
Write the bitcode file's string table.