[cfe-dev] Function-level metadata for OpenCL (was Re: OpenCL support)

Peter Collingbourne peter at pcc.me.uk
Thu Dec 16 14:33:45 PST 2010


On Thu, Dec 16, 2010 at 06:16:25PM -0000, Anton Lokhmotov wrote:
> Mike Gist wrote:
> > You could also consider placing all kernel functions in a 'kernel'
> > section, or adding a function attribute for kernels.
> Unlike in Clang, function attribute bit-fields in LLVM are pretty crowded
> (only couple of bits are unused?).  Besides, we do not want to represent
> differently the kernel qualifier and optional kernel qualifiers, which
> require storing <typen> and X, Y, Z values. (I don't even want to think how
> one would mangle the optional qualifiers into a kernel name and then
> demangle.)
>
> That's why we propose to use metadata for this purpose.  Does anyone have a
> better idea?

I agree that metadata should be used for function qualifiers;
a prerequisite being support for non-discardable function-level
metadata, which would need to be added to LLVM.  I'm undecided on
whether __kernel should also be represented by metadata; there is
precedent (PTX backend) for using the calling convention.

I do have a concern though with the semantics of the inliner when it
needs to inline a function with metadata.  One possibility would be to
discard the callee's metadata, or somehow merge it with the caller's.
Discarding seems like the right solution for OpenCL and a good starting
point (in future we may wish to add attributes to metadata nodes like
the 'appending' linkage for globals) but sounds like something that
should be discussed first.

Thanks,
-- 
Peter



More information about the cfe-dev mailing list