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

Guo, Yejun yejun.guo at intel.com
Thu Aug 13 19:03:48 PDT 2015


Hi Manasi,

Please refer to the patch I sent yesterday to handle LLVM 3.3. We'd use '0' instead of ' llvm::sys::fs::F_RW' for LLVM3.3, thanks.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Manasi Navare
Sent: Thursday, August 13, 2015 8:59 PM
To: beignet at lists.freedesktop.org; Song, Ruiling
Cc: Navare, Manasi D
Subject: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH] in clCompileProgram OpenCL API

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

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list