29 function_ref<std::unique_ptr<TargetMachine>()> TMFactory,
31 std::unique_ptr<TargetMachine>
TM = TMFactory();
33 if (TM->addPassesToEmitFile(CodeGenPasses, OS,
nullptr, FileType))
35 CodeGenPasses.
run(*M);
41 const std::function<std::unique_ptr<TargetMachine>()> &TMFactory,
45 if (OSs.
size() == 1) {
48 codegen(M.get(), *OSs[0], TMFactory, FileType);
59 std::move(M), OSs.
size(),
60 [&](std::unique_ptr<Module> MPart) {
72 BCOSs[ThreadCount]->write(BC.
begin(), BC.
size());
73 BCOSs[ThreadCount]->flush();
78 CodegenThreadPool.async(
87 std::unique_ptr<Module> MPartInCtx = std::move(MOrErr.
get());
89 codegen(MPartInCtx.get(), *ThreadOS, TMFactory, FileType);
static void codegen(Module *M, llvm::raw_pwrite_stream &OS, function_ref< std::unique_ptr< TargetMachine >()> TMFactory, TargetMachine::CodeGenFileType FileType)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
void SplitModule(std::unique_ptr< Module > M, unsigned N, function_ref< void(std::unique_ptr< Module > MPart)> ModuleCallback, bool PreserveLocals=false)
Splits the module M into N linkable partitions.
An efficient, type-erasing, non-owning reference to a callable.
A raw_ostream that writes to an SmallVector or SmallString.
std::unique_ptr< Module > splitCodeGen(std::unique_ptr< Module > M, ArrayRef< raw_pwrite_stream *> OSs, ArrayRef< llvm::raw_pwrite_stream *> BCOSs, const std::function< std::unique_ptr< TargetMachine >()> &TMFactory, TargetMachine::CodeGenFileType FileType=TargetMachine::CGFT_ObjectFile, bool PreserveLocals=false)
Split M into OSs.size() partitions, and generate code for each.
Tagged union holding either a T or a Error.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
A ThreadPool for asynchronous parallel execution on a defined number of threads.
PassManager manages ModulePassManagers.
This is an important class for using LLVM in a threaded context.
size_t size() const
size - Get the array size.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
void WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
bool run(Module &M)
run - Execute all of the passes scheduled for execution.
Module.h This file contains the declarations for the Module class.
reference get()
Returns a reference to the stored T value.
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().
Provides ErrorOr<T> smart pointer.
An abstract base class for streams implementations that also support a pwrite operation.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit...
bool empty() const
empty - Check if the array is empty.