fix issue when build against llvm3.3

Submitted by Guo Yejun on Aug. 12, 2015, 1:09 a.m.

Details

Message ID 1439341782-21040-1-git-send-email-yejun.guo@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Guo Yejun Aug. 12, 2015, 1:09 a.m.
llvm 3.3 has a different constructure of llvm::raw_fd_ostream

Signed-off-by: Guo Yejun <yejun.guo@intel.com>
---
 backend/src/backend/program.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 9caf1ac..5f4277a 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -813,7 +813,16 @@  namespace gbe {
       }
 
       // Dump the LLVM if requested.
-      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)
+      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 3)
+      if (!dumpLLVMFileName.empty()) {
+        std::string err;
+        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),
+                                      err, 0);
+        if (err.empty()) {
+          out_module->print(ostream, 0);
+        } //Otherwise, you'll have to make do without the dump.
+      }
+      #elif (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)
       if (!dumpLLVMFileName.empty()) {
         std::string err;
         llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),

Comments

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Guo Yejun

> Sent: Wednesday, August 12, 2015 9:10 AM

> To: beignet@lists.freedesktop.org

> Cc: Guo, Yejun

> Subject: [Beignet] [PATCH] fix issue when build against llvm3.3

> 

> llvm 3.3 has a different constructure of llvm::raw_fd_ostream

> 

> Signed-off-by: Guo Yejun <yejun.guo@intel.com>

> ---

>  backend/src/backend/program.cpp | 11 ++++++++++-

>  1 file changed, 10 insertions(+), 1 deletion(-)

> 

> diff --git a/backend/src/backend/program.cpp

> b/backend/src/backend/program.cpp index 9caf1ac..5f4277a 100644

> --- a/backend/src/backend/program.cpp

> +++ b/backend/src/backend/program.cpp

> @@ -813,7 +813,16 @@ namespace gbe {

>        }

> 

>        // Dump the LLVM if requested.

> -      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)

> +      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 3)

> +      if (!dumpLLVMFileName.empty()) {

> +        std::string err;

> +        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),

> +                                      err, 0);

I think we can avoid copying whole piece of code, as it seems only the third argument is different.

> +        if (err.empty()) {

> +          out_module->print(ostream, 0);

> +        } //Otherwise, you'll have to make do without the dump.

> +      }

> +      #elif (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)

>        if (!dumpLLVMFileName.empty()) {

>          std::string err;

>          llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),

> --

> 1.9.1

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet
Sure, let me send v2 for this style.

-----Original Message-----
From: Song, Ruiling 

Sent: Thursday, August 13, 2015 9:57 AM
To: Guo, Yejun; beignet@lists.freedesktop.org
Cc: Guo, Yejun
Subject: RE: [Beignet] [PATCH] fix issue when build against llvm3.3



> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf 

> Of Guo Yejun

> Sent: Wednesday, August 12, 2015 9:10 AM

> To: beignet@lists.freedesktop.org

> Cc: Guo, Yejun

> Subject: [Beignet] [PATCH] fix issue when build against llvm3.3

> 

> llvm 3.3 has a different constructure of llvm::raw_fd_ostream

> 

> Signed-off-by: Guo Yejun <yejun.guo@intel.com>

> ---

>  backend/src/backend/program.cpp | 11 ++++++++++-

>  1 file changed, 10 insertions(+), 1 deletion(-)

> 

> diff --git a/backend/src/backend/program.cpp 

> b/backend/src/backend/program.cpp index 9caf1ac..5f4277a 100644

> --- a/backend/src/backend/program.cpp

> +++ b/backend/src/backend/program.cpp

> @@ -813,7 +813,16 @@ namespace gbe {

>        }

> 

>        // Dump the LLVM if requested.

> -      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)

> +      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 3)

> +      if (!dumpLLVMFileName.empty()) {

> +        std::string err;

> +        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),

> +                                      err, 0);

I think we can avoid copying whole piece of code, as it seems only the third argument is different.

> +        if (err.empty()) {

> +          out_module->print(ostream, 0);

> +        } //Otherwise, you'll have to make do without the dump.

> +      }

> +      #elif (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)

>        if (!dumpLLVMFileName.empty()) {

>          std::string err;

>          llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),

> --

> 1.9.1

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet