[7/7] backend: Turn on ASM dump.

Submitted by Manasi Navare on Aug. 12, 2015, 5:54 a.m.

Details

Message ID 1439358860-6874-8-git-send-email-manasi.d.navare@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Manasi Navare Aug. 12, 2015, 5:54 a.m.
Open the file specified for the ASM dump and write the assembly to it.

Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
Signed-off-by: Laura Ekstrand <laura.d.ekstrand@intel.com>
---
 backend/src/backend/gen_context.cpp | 8 ++++++++
 backend/src/backend/program.cpp     | 3 +++
 2 files changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 6353b85..2983d52 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2299,6 +2299,14 @@  namespace gbe
     if (OCL_OUTPUT_ASM)
       outputAssembly(stdout, genKernel);
 
+    if (this->asmFileName) {
+      FILE *asmDumpStream = fopen(this->asmFileName, "a");
+      if (asmDumpStream) {
+        outputAssembly(asmDumpStream, genKernel);
+        fclose(asmDumpStream);
+      }
+    }
+
     return true;
   }
 
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 6f64413..6d539a9 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -840,6 +840,9 @@  namespace gbe {
       }
       #endif
 
+      FILE *asmDumpStream = fopen(dumpASMFileName.c_str(), "w");  
+      if (asmDumpStream)
+        fclose(asmDumpStream);
       p = gbe_program_new_from_llvm(deviceID, NULL, out_module, llvm_ctx, dumpASMFileName.c_str(), stringSize,
                                     err, errSize, optLevel);
       if (err != NULL)

Comments

The patchset LGTM.
But still I have some comments. The patchset work for clBuildProgram().
But you don't handle clCompileProgram() and clLinkProgram(). You need to double-check whether this is needed.
If needed, you have to refine the dump-llvm logic into BuildModuleFromSource, so that build/compile both share the logic.
And the dump-asm logic will be also needed in genProgramBuildFromLLVM()

Thanks!
Ruiling