[Mesa-dev] [PATCH v2] clover: assert struct argument is compiled usably

Vedran Miletić vedran at miletic.net
Thu Oct 6 14:34:42 UTC 2016


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 on Clang versions
containing https://reviews.llvm.org/D20168 or an equivalent patch.

Signed-off-by: Vedran Miletić <vedran at miletic.net>
---
 src/gallium/state_trackers/clover/llvm/codegen/common.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
index 834b06a..2d1759e 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
@@ -78,6 +78,9 @@ namespace {
 
       for (const auto &arg : f.args()) {
          const auto arg_type = arg.getType();
+         assert(!(arg_type->isPointerTy() && arg.hasByValAttr() &&
+                arg_type->getPointerElementType()->isStructTy()) &&
+                "Unable to handle struct compiled as pointer with byval.");
 
          // OpenCL 1.2 specification, Ch. 6.1.5: "A built-in data
          // type that is not a power of two bytes in size must be
-- 
2.7.4



More information about the mesa-dev mailing list