From: Vedran Miletić <ved...@miletic.net>

Make sure that a struct argument did not get compiled into a pointer
type with the byval attribute. If we try to handle the pointer with
byval, we end up with the pointer size instead of the struct size.

Struct arguments on AMD GPUs will work correctly once Clang gets patched
with http://reviews.llvm.org/D20168 or an equivalent patch.

Reviewed-by: Serge Martin <edb+m...@sigluy.net>

Cc: 12.0 <mesa-sta...@lists.freedesktop.org>
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index e2cadda..03487d6 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -461,6 +461,10 @@ namespace {
       for (const auto &arg: kernel_func->args()) {
 
          llvm::Type *arg_type = arg.getType();
+         assert(!(arg_type->isPointerTy() && arg.hasByValAttr() &&
+                arg_type->getPointerElementType()->isStructTy()) &&
+                "Unable to handle struct compiled as pointer with byval.");
+
          const unsigned arg_store_size = TD.getTypeStoreSize(arg_type);
 
          // OpenCL 1.2 specification, Ch. 6.1.5: "A built-in data
-- 
2.5.5

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

Reply via email to