From 6abede9c335c46fe1d9bce5b6d2a7fbee97b5a63 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 21 Jun 2024 17:01:11 -0400 Subject: [PATCH] xo-jit: print IR before- and after- optimization --- src/jit/MachPipeline.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/jit/MachPipeline.cpp b/src/jit/MachPipeline.cpp index 1720b545..293f8625 100644 --- a/src/jit/MachPipeline.cpp +++ b/src/jit/MachPipeline.cpp @@ -519,9 +519,25 @@ namespace xo { /* validate! always validate! */ llvm::verifyFunction(*fn); + if (log) { + std::string buf; + llvm::raw_string_ostream ss(buf); + fn->print(ss); + + log(xtag("IR-before-opt", buf)); + } + /* optimize! improves IR */ ir_pipeline_->run_pipeline(*fn); // llvm_fpmgr_->run(*fn, *llvm_famgr_); + if (log) { + std::string buf; + llvm::raw_string_ostream ss(buf); + fn->print(ss); + + log(xtag("IR-after-opt", buf)); + } + return fn; }