30 function_ref<std::unique_ptr<TargetMachine>()> TMFactory,
32 std::unique_ptr<TargetMachine>
TM = TMFactory();
34 if (TM->addPassesToEmitFile(CodeGenPasses, OS, FileType))
36 CodeGenPasses.
run(*M);
42 const std::function<std::unique_ptr<TargetMachine>()> &TMFactory,
46 if (OSs.
size() == 1) {
60 std::move(M), OSs.
size(),
61 [&](std::unique_ptr<Module> MPart) {
73 BCOSs[ThreadCount]->write(BC.
begin(), BC.
size());
74 BCOSs[ThreadCount]->flush();
79 CodegenThreadPool.async(
88 std::unique_ptr<Module> MPartInCtx = std::move(MOrErr.
get());
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.
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.
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.
size_t size() const
size - Get the array size.
PassManager manages ModulePassManagers.
This is an important class for using LLVM in a threaded context.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
bool empty() const
empty - Check if the array is empty.
cl::opt< TargetMachine::CodeGenFileType > FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile), cl::desc("Choose a file type (not all types are supported by all targets):"), cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile,"asm","Emit an assembly ('.s') file"), clEnumValN(TargetMachine::CGFT_ObjectFile,"obj","Emit a native object ('.o') file"), clEnumValN(TargetMachine::CGFT_Null,"null","Emit nothing, for performance testing")))
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().
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false)
Write the specified module to the specified raw output stream.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
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...
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 FT=TargetMachine::CGFT_ObjectFile, bool PreserveLocals=false)
Split M into OSs.size() partitions, and generate code for each.