Re: [Mesa-dev] [PATCH v5] clover: restore support for LLVM <= 3.9

2016-11-24 Thread Francisco Jerez
Jan Vesely  writes:

> On Tue, 2016-11-22 at 20:25 +0100, Vedran Miletić wrote:
>> The commit 8e430ff8b060b4e8e922bae24b3c57837da6ea77 support for LLVM
>> 3.9 and older versionsin  Clover. This patch restores it and refactors
>> the support using Clover compatibility layer for LLVM.
>> 
>> v2: merged #ifdef blocks
>> v3: added support for LLVM 3.6-3.8
>> v4: add missing #ifdef around 
>> v5: simplify using templates and lambda
>> 
>> Signed-off-by: Vedran Miletić 
>> Reviewed-by[v2]: Jan Vesely 
>> Tested-by[v4]: Vinson Lee 
>> Tested-by[v4]: Pierre Moreau 
>> Reviewed-by: Francisco Jerez 
>> ---
>>  .../state_trackers/clover/llvm/codegen/bitcode.cpp |  9 +++--
>>  src/gallium/state_trackers/clover/llvm/compat.hpp  | 18 
>> ++
>>  2 files changed, 21 insertions(+), 6 deletions(-)
>> 
>> diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp 
>> b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
>> index 5dcc4f8..d09207b 100644
>> --- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
>> +++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
>> @@ -32,6 +32,7 @@
>>  ///
>>  
>>  #include "llvm/codegen.hpp"
>> +#include "llvm/compat.hpp"
>>  #include "llvm/metadata.hpp"
>>  #include "core/error.hpp"
>>  #include "util/algorithm.hpp"
>> @@ -99,13 +100,9 @@ clover::llvm::parse_module_library(const module , 
>> ::llvm::LLVMContext ,
>> auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
>>  as_string(m.secs[0].data), " "), 
>> ctx);
>>  
>> -   if (::llvm::Error err = mod.takeError()) {
>> -  std::string msg;
>> -  ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase 
>> ) {
>> - msg = EIB.message();
>> - fail(r_log, error(CL_INVALID_PROGRAM), msg.c_str());
>
> interesting that this used to pass char * and now switched to
> std::string. was that a leftover from the times of compat::string?

I don't think so, it was 8e430ff8b060b4e8e922bae24b3c57837da6ea77 that
changed the argument to be a char * for some reason.

> you can add my RB to v5.
>
> Reviewed-by: Jan Vesely 
>
> Jan
>
>> +   compat::handle_module_error(mod, [&](const std::string ) {
>> + fail(r_log, error(CL_INVALID_PROGRAM), s);
>>});
>> -   }
>>  
>> return std::unique_ptr<::llvm::Module>(std::move(*mod));
>>  }
>> diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
>> b/src/gallium/state_trackers/clover/llvm/compat.hpp
>> index a963cff..fc257ec 100644
>> --- a/src/gallium/state_trackers/clover/llvm/compat.hpp
>> +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
>> @@ -39,6 +39,11 @@
>>  #include 
>>  #include 
>>  #include 
>> +#if HAVE_LLVM >= 0x0400
>> +#include 
>> +#else
>> +#include 
>> +#endif
>>  
>>  #if HAVE_LLVM >= 0x0307
>>  #include 
>> @@ -158,6 +163,19 @@ namespace clover {
>>  #else
>>   const auto default_reloc_model = ::llvm::Reloc::Default;
>>  #endif
>> +
>> + template inline void
>> + handle_module_error(M , const F ) {
>> +#if HAVE_LLVM >= 0x0400
>> +if (::llvm::Error err = mod.takeError())
>> +   ::llvm::handleAllErrors(std::move(err), 
>> [&](::llvm::ErrorInfoBase ) {
>> + f(eib.message());
>> +  });
>> +#else
>> +if (!mod)
>> +   f(mod.getError().message());
>> +#endif
>> + }
>>}
>> }
>>  }
>
> -- 
> Jan Vesely 


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5] clover: restore support for LLVM <= 3.9

2016-11-24 Thread Francisco Jerez
Vedran Miletić  writes:

> The commit 8e430ff8b060b4e8e922bae24b3c57837da6ea77 support for LLVM
> 3.9 and older versionsin  Clover. This patch restores it and refactors
> the support using Clover compatibility layer for LLVM.
>
> v2: merged #ifdef blocks
> v3: added support for LLVM 3.6-3.8
> v4: add missing #ifdef around 
> v5: simplify using templates and lambda
>
> Signed-off-by: Vedran Miletić 
> Reviewed-by[v2]: Jan Vesely 
> Tested-by[v4]: Vinson Lee 
> Tested-by[v4]: Pierre Moreau 
> Reviewed-by: Francisco Jerez 
> ---
>  .../state_trackers/clover/llvm/codegen/bitcode.cpp |  9 +++--
>  src/gallium/state_trackers/clover/llvm/compat.hpp  | 18 
> ++
>  2 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp 
> b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> index 5dcc4f8..d09207b 100644
> --- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> @@ -32,6 +32,7 @@
>  ///
>  
>  #include "llvm/codegen.hpp"
> +#include "llvm/compat.hpp"
>  #include "llvm/metadata.hpp"
>  #include "core/error.hpp"
>  #include "util/algorithm.hpp"
> @@ -99,13 +100,9 @@ clover::llvm::parse_module_library(const module , 
> ::llvm::LLVMContext ,
> auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
>  as_string(m.secs[0].data), " "), 
> ctx);
>  
> -   if (::llvm::Error err = mod.takeError()) {
> -  std::string msg;
> -  ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase 
> ) {
> - msg = EIB.message();
> - fail(r_log, error(CL_INVALID_PROGRAM), msg.c_str());
> +   compat::handle_module_error(mod, [&](const std::string ) {
> + fail(r_log, error(CL_INVALID_PROGRAM), s);
>});
> -   }
>  
> return std::unique_ptr<::llvm::Module>(std::move(*mod));
>  }
> diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
> b/src/gallium/state_trackers/clover/llvm/compat.hpp
> index a963cff..fc257ec 100644
> --- a/src/gallium/state_trackers/clover/llvm/compat.hpp
> +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
> @@ -39,6 +39,11 @@
>  #include 
>  #include 
>  #include 
> +#if HAVE_LLVM >= 0x0400
> +#include 
> +#else
> +#include 
> +#endif
>  
>  #if HAVE_LLVM >= 0x0307
>  #include 
> @@ -158,6 +163,19 @@ namespace clover {
>  #else
>   const auto default_reloc_model = ::llvm::Reloc::Default;
>  #endif
> +
> + template inline void

I've dropped the 'inline' keyword (template functions implicitly have
inline linkage in C++), fixed some minor spelling issues in the commit
message and landed the patch.  Thanks!

> + handle_module_error(M , const F ) {
> +#if HAVE_LLVM >= 0x0400
> +if (::llvm::Error err = mod.takeError())
> +   ::llvm::handleAllErrors(std::move(err), 
> [&](::llvm::ErrorInfoBase ) {
> + f(eib.message());
> +  });
> +#else
> +if (!mod)
> +   f(mod.getError().message());
> +#endif
> + }
>}
> }
>  }
> -- 
> 2.7.4


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5] clover: restore support for LLVM <= 3.9

2016-11-24 Thread Jan Vesely
On Tue, 2016-11-22 at 20:25 +0100, Vedran Miletić wrote:
> The commit 8e430ff8b060b4e8e922bae24b3c57837da6ea77 support for LLVM
> 3.9 and older versionsin  Clover. This patch restores it and refactors
> the support using Clover compatibility layer for LLVM.
> 
> v2: merged #ifdef blocks
> v3: added support for LLVM 3.6-3.8
> v4: add missing #ifdef around 
> v5: simplify using templates and lambda
> 
> Signed-off-by: Vedran Miletić 
> Reviewed-by[v2]: Jan Vesely 
> Tested-by[v4]: Vinson Lee 
> Tested-by[v4]: Pierre Moreau 
> Reviewed-by: Francisco Jerez 
> ---
>  .../state_trackers/clover/llvm/codegen/bitcode.cpp |  9 +++--
>  src/gallium/state_trackers/clover/llvm/compat.hpp  | 18 
> ++
>  2 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp 
> b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> index 5dcc4f8..d09207b 100644
> --- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> @@ -32,6 +32,7 @@
>  ///
>  
>  #include "llvm/codegen.hpp"
> +#include "llvm/compat.hpp"
>  #include "llvm/metadata.hpp"
>  #include "core/error.hpp"
>  #include "util/algorithm.hpp"
> @@ -99,13 +100,9 @@ clover::llvm::parse_module_library(const module , 
> ::llvm::LLVMContext ,
> auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
>  as_string(m.secs[0].data), " "), 
> ctx);
>  
> -   if (::llvm::Error err = mod.takeError()) {
> -  std::string msg;
> -  ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase 
> ) {
> - msg = EIB.message();
> - fail(r_log, error(CL_INVALID_PROGRAM), msg.c_str());

interesting that this used to pass char * and now switched to
std::string. was that a leftover from the times of compat::string?
you can add my RB to v5.

Reviewed-by: Jan Vesely 

Jan

> +   compat::handle_module_error(mod, [&](const std::string ) {
> + fail(r_log, error(CL_INVALID_PROGRAM), s);
>});
> -   }
>  
> return std::unique_ptr<::llvm::Module>(std::move(*mod));
>  }
> diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
> b/src/gallium/state_trackers/clover/llvm/compat.hpp
> index a963cff..fc257ec 100644
> --- a/src/gallium/state_trackers/clover/llvm/compat.hpp
> +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
> @@ -39,6 +39,11 @@
>  #include 
>  #include 
>  #include 
> +#if HAVE_LLVM >= 0x0400
> +#include 
> +#else
> +#include 
> +#endif
>  
>  #if HAVE_LLVM >= 0x0307
>  #include 
> @@ -158,6 +163,19 @@ namespace clover {
>  #else
>   const auto default_reloc_model = ::llvm::Reloc::Default;
>  #endif
> +
> + template inline void
> + handle_module_error(M , const F ) {
> +#if HAVE_LLVM >= 0x0400
> +if (::llvm::Error err = mod.takeError())
> +   ::llvm::handleAllErrors(std::move(err), 
> [&](::llvm::ErrorInfoBase ) {
> + f(eib.message());
> +  });
> +#else
> +if (!mod)
> +   f(mod.getError().message());
> +#endif
> + }
>}
> }
>  }

-- 
Jan Vesely 

signature.asc
Description: This is a digitally signed message part
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5] clover: restore support for LLVM <= 3.9

2016-11-22 Thread Vinson Lee
On Tue, Nov 22, 2016 at 11:25 AM, Vedran Miletić  wrote:
> The commit 8e430ff8b060b4e8e922bae24b3c57837da6ea77 support for LLVM
> 3.9 and older versionsin  Clover. This patch restores it and refactors
> the support using Clover compatibility layer for LLVM.
>
> v2: merged #ifdef blocks
> v3: added support for LLVM 3.6-3.8
> v4: add missing #ifdef around 
> v5: simplify using templates and lambda
>
> Signed-off-by: Vedran Miletić 
> Reviewed-by[v2]: Jan Vesely 
> Tested-by[v4]: Vinson Lee 
> Tested-by[v4]: Pierre Moreau 
> Reviewed-by: Francisco Jerez 
> ---
>  .../state_trackers/clover/llvm/codegen/bitcode.cpp |  9 +++--
>  src/gallium/state_trackers/clover/llvm/compat.hpp  | 18 
> ++
>  2 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp 
> b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> index 5dcc4f8..d09207b 100644
> --- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
> @@ -32,6 +32,7 @@
>  ///
>
>  #include "llvm/codegen.hpp"
> +#include "llvm/compat.hpp"
>  #include "llvm/metadata.hpp"
>  #include "core/error.hpp"
>  #include "util/algorithm.hpp"
> @@ -99,13 +100,9 @@ clover::llvm::parse_module_library(const module , 
> ::llvm::LLVMContext ,
> auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
>  as_string(m.secs[0].data), " "), 
> ctx);
>
> -   if (::llvm::Error err = mod.takeError()) {
> -  std::string msg;
> -  ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase 
> ) {
> - msg = EIB.message();
> - fail(r_log, error(CL_INVALID_PROGRAM), msg.c_str());
> +   compat::handle_module_error(mod, [&](const std::string ) {
> + fail(r_log, error(CL_INVALID_PROGRAM), s);
>});
> -   }
>
> return std::unique_ptr<::llvm::Module>(std::move(*mod));
>  }
> diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
> b/src/gallium/state_trackers/clover/llvm/compat.hpp
> index a963cff..fc257ec 100644
> --- a/src/gallium/state_trackers/clover/llvm/compat.hpp
> +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
> @@ -39,6 +39,11 @@
>  #include 
>  #include 
>  #include 
> +#if HAVE_LLVM >= 0x0400
> +#include 
> +#else
> +#include 
> +#endif
>
>  #if HAVE_LLVM >= 0x0307
>  #include 
> @@ -158,6 +163,19 @@ namespace clover {
>  #else
>   const auto default_reloc_model = ::llvm::Reloc::Default;
>  #endif
> +
> + template inline void
> + handle_module_error(M , const F ) {
> +#if HAVE_LLVM >= 0x0400
> +if (::llvm::Error err = mod.takeError())
> +   ::llvm::handleAllErrors(std::move(err), 
> [&](::llvm::ErrorInfoBase ) {
> + f(eib.message());
> +  });
> +#else
> +if (!mod)
> +   f(mod.getError().message());
> +#endif
> + }
>}
> }
>  }
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Tested that this patch fixes build with llvm-3.8.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98740
Tested-by: Vinson Lee 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v5] clover: restore support for LLVM <= 3.9

2016-11-22 Thread Vedran Miletić
The commit 8e430ff8b060b4e8e922bae24b3c57837da6ea77 support for LLVM
3.9 and older versionsin  Clover. This patch restores it and refactors
the support using Clover compatibility layer for LLVM.

v2: merged #ifdef blocks
v3: added support for LLVM 3.6-3.8
v4: add missing #ifdef around 
v5: simplify using templates and lambda

Signed-off-by: Vedran Miletić 
Reviewed-by[v2]: Jan Vesely 
Tested-by[v4]: Vinson Lee 
Tested-by[v4]: Pierre Moreau 
Reviewed-by: Francisco Jerez 
---
 .../state_trackers/clover/llvm/codegen/bitcode.cpp |  9 +++--
 src/gallium/state_trackers/clover/llvm/compat.hpp  | 18 ++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp 
b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
index 5dcc4f8..d09207b 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
@@ -32,6 +32,7 @@
 ///
 
 #include "llvm/codegen.hpp"
+#include "llvm/compat.hpp"
 #include "llvm/metadata.hpp"
 #include "core/error.hpp"
 #include "util/algorithm.hpp"
@@ -99,13 +100,9 @@ clover::llvm::parse_module_library(const module , 
::llvm::LLVMContext ,
auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
 as_string(m.secs[0].data), " "), ctx);
 
-   if (::llvm::Error err = mod.takeError()) {
-  std::string msg;
-  ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase ) {
- msg = EIB.message();
- fail(r_log, error(CL_INVALID_PROGRAM), msg.c_str());
+   compat::handle_module_error(mod, [&](const std::string ) {
+ fail(r_log, error(CL_INVALID_PROGRAM), s);
   });
-   }
 
return std::unique_ptr<::llvm::Module>(std::move(*mod));
 }
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
b/src/gallium/state_trackers/clover/llvm/compat.hpp
index a963cff..fc257ec 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -39,6 +39,11 @@
 #include 
 #include 
 #include 
+#if HAVE_LLVM >= 0x0400
+#include 
+#else
+#include 
+#endif
 
 #if HAVE_LLVM >= 0x0307
 #include 
@@ -158,6 +163,19 @@ namespace clover {
 #else
  const auto default_reloc_model = ::llvm::Reloc::Default;
 #endif
+
+ template inline void
+ handle_module_error(M , const F ) {
+#if HAVE_LLVM >= 0x0400
+if (::llvm::Error err = mod.takeError())
+   ::llvm::handleAllErrors(std::move(err), 
[&](::llvm::ErrorInfoBase ) {
+ f(eib.message());
+  });
+#else
+if (!mod)
+   f(mod.getError().message());
+#endif
+ }
   }
}
 }
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev