mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #57610 from kitaisreal/jit-add-assembly-printer
CHJIT add assembly printer
This commit is contained in:
commit
fdfd1481df
@ -244,6 +244,31 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef PRINT_ASSEMBLY
|
||||
|
||||
class AssemblyPrinter
|
||||
{
|
||||
public:
|
||||
explicit AssemblyPrinter(llvm::TargetMachine &target_machine_)
|
||||
: target_machine(target_machine_)
|
||||
{
|
||||
}
|
||||
|
||||
void print(llvm::Module & module)
|
||||
{
|
||||
llvm::legacy::PassManager pass_manager;
|
||||
target_machine.Options.MCOptions.AsmVerbose = true;
|
||||
if (target_machine.addPassesToEmitFile(pass_manager, llvm::errs(), nullptr, llvm::CodeGenFileType::CGFT_AssemblyFile))
|
||||
throw Exception(ErrorCodes::CANNOT_COMPILE_CODE, "MachineCode cannot be printed");
|
||||
|
||||
pass_manager.run(module);
|
||||
}
|
||||
private:
|
||||
llvm::TargetMachine & target_machine;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/** MemoryManager for module.
|
||||
* Keep total allocated size during RuntimeDyld linker execution.
|
||||
*/
|
||||
@ -375,6 +400,11 @@ CHJIT::CompiledModule CHJIT::compileModule(std::unique_ptr<llvm::Module> module)
|
||||
{
|
||||
runOptimizationPassesOnModule(*module);
|
||||
|
||||
#ifdef PRINT_ASSEMBLY
|
||||
AssemblyPrinter assembly_printer(*machine);
|
||||
assembly_printer.print(*module);
|
||||
#endif
|
||||
|
||||
auto buffer = compiler->compile(*module);
|
||||
|
||||
llvm::Expected<std::unique_ptr<llvm::object::ObjectFile>> object = llvm::object::ObjectFile::createObjectFile(*buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user