I would like to gather more information about how different implementations
represent OpenCL C programs in LLVM-IR in order to collate the best practice
and make it into a standard.
We at Intel are also using metadata for our implementation. This
approach is very useful for a few reasons:
First, when compiling OpenCL C code to llvm, some important information
about the kernel arguments is lost. i.e. typedefs are lost, structures
are sometimes disassembled. We're adding a string containing the
interesting part original function signature.
Hmm, if we want to standardise this, we need to define which parts of the
signature are considered "interesting".
Second, we use a global metadata node, which enumerates all the kernel
functions. This can be used to quickly enumerate the kernels in a
program, instead of passing the whole module.
We are doing exactly the same:
Third, for each kernel we hold the kernel attributes in the same
metadata: vector type hint, required workgroup size and workgroup size
Do you use one metadata node per kernel? (It seems we are doing it
differently.) Do these nodes have the same format (three fields per
kernel)? What do you use for defaults?
Last, we also hold in the metadata a list of the local variables
defined in that kernel.
Do you mean kernel-scope variables declared in the local address space? How
about kernel-scope variables declared in the constant address space? We
are bringing both classes to the program scope, prefixing them with the
kernel's name. Do you have any views on that?