[Mesa-stable] [PATCH 1/2] clover: assert struct argument is compiled usably

Serge Martin edb+mesa at sigluy.net
Wed Jun 1 12:36:14 UTC 2016


From: Vedran Miletić <vedran at 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+mesa at sigluy.net>

Cc: 12.0 <mesa-stable at 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



More information about the mesa-stable mailing list