clover/llvm: Define function for bitcode print-out.
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 17 May 2016 14:02:58 +0000 (16:02 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 12 Jul 2016 03:34:33 +0000 (20:34 -0700)
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
src/gallium/state_trackers/clover/llvm/invocation.cpp

index d4c8addeea3e0ae93df49d843c1fcbacc21c17ca..a51411d9df6e1f909c581d797d53c3416c2728b3 100644 (file)
@@ -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