[Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH] in clCompileProgram OpenCL API

Manasi Navare manasi.d.navare at intel.com
Thu Aug 13 05:58:57 PDT 2015


Allows the user to request a dump of the LLVM-generated IR to the file
specified in [PATH] through clCompileProgram options

Signed-off-by: Manasi Navare <manasi.d.navare at intel.com>
---
 backend/src/backend/program.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 6d539a9..1b3fc82 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -894,6 +894,27 @@ namespace gbe {
         err += *errSize;
       }
 
+     // Dump the LLVM if requested.
+      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)
+      if (!dumpLLVMFileName.empty()) {
+        std::string err;
+        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),
+                                      err, llvm::sys::fs::F_RW);
+        if (err.empty()) {
+          out_module->print(ostream, 0);
+        } //Otherwise, you'll have to make do without the dump.
+      }
+      #else
+      if (!dumpLLVMFileName.empty()) {
+        std::error_code err;
+        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),
+                                      err, llvm::sys::fs::F_RW);
+        if (!err) {
+          out_module->print(ostream, 0);
+        } //Otherwise, you'll have to make do without the dump.
+      }
+      #endif
+
       p = gbe_program_new_gen_program(deviceID, out_module, NULL);
 
       if (OCL_OUTPUT_BUILD_LOG && options)
-- 
1.9.1



More information about the Beignet mailing list