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

Francisco Jerez currojerez at riseup.net
Sat Jun 4 02:18:32 UTC 2016


Serge Martin <edb+mesa at sigluy.net> writes:

> 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.
>
Ugh, is that a bug in the code below?  How are byval pointers supposed
to be handled here?  Exactly as if the argument wasn't a pointer at all
by providing a copy of the pointed-to object as-is in the kernel input
buffer?  In that case wouldn't the code below need to pass the correct
size of the pointed-to object as target/api size rather than the size of
the pointer?

> 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
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20160603/e25a3be4/attachment-0001.sig>


More information about the mesa-stable mailing list