[Mesa-dev,26/47] clover/llvm: Define function for bitcode print-out.

Submitted by Francisco Jerez on July 4, 2016, 12:51 a.m.

Details

Message ID 20160704005156.5703-27-currojerez@riseup.net
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Francisco Jerez July 4, 2016, 12:51 a.m.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index d4c8add..a51411d 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -433,6 +433,14 @@  namespace {
                                  c);
    }
 
+   std::string
+   print_module_bitcode(const ::llvm::Module &mod) {
+      std::string s;
+      ::llvm::raw_string_ostream os { s };
+      mod.print(os, NULL);
+      return os.str();
+   }
+
    std::vector<char>
    emit_code(::llvm::Module &mod, const target &target,
              TargetMachine::CodeGenFileType ft,
@@ -572,13 +580,8 @@  clover::compile_program_llvm(const std::string &source,
 
    optimize(*mod, c->getCodeGenOpts().OptimizationLevel);
 
-   if (has_flag(debug::llvm)) {
-      std::string log;
-      raw_string_ostream s_log(log);
-      mod->print(s_log, NULL);
-      s_log.flush();
-      debug::log(".ll", log);
-    }
+   if (has_flag(debug::llvm))
+      debug::log(".ll", print_module_bitcode(*mod));
 
    module m;
    // Build the clover::module