[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 13 12:43:11 PDT 2017


yaxunl created this revision.

Currently block is translated to a structure equivalent to

  struct Block {
    void *isa;
    int flags;
    int reserved;
    void *invoke;
    void *descriptor;
  };

Except `invoke`, which is the pointer to the block invoke function,
all other fields are useless for OpenCL, which clutter the IR and
also waste memory since the block struct is passed to the block
invoke function as argument.

On the other hand, the size and alignment of the block struct is
not stored in the struct, which causes difficulty to implement
__enqueue_kernel as library function, since the library function
needs to know the size and alignment of the argument which needs
to be passed to the kernel.

This patch removes the useless fields from the block struct and adds
size and align fields. The equivalent block struct will become

  struct Block {
    int size;
    int align;
    generic void *invoke;
  };

It also changes the pointer to the invoke function to be
a generic pointer since the address space of a function
may not be private on certain targets.


https://reviews.llvm.org/D37822

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGen/blocks-opencl.cl
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37822.115096.patch
Type: text/x-patch
Size: 39846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170913/c802ee5f/attachment-0001.bin>


More information about the cfe-commits mailing list