<div class="gmail_quote">On 16 December 2010 14:33, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

On Thu, Dec 16, 2010 at 06:16:25PM -0000, Anton Lokhmotov wrote:<br>
> Mike Gist wrote:<br>
> > You could also consider placing all kernel functions in a 'kernel'<br>
> > section, or adding a function attribute for kernels.<br>
> Unlike in Clang, function attribute bit-fields in LLVM are pretty crowded<br>
> (only couple of bits are unused?).  Besides, we do not want to represent<br>
> differently the kernel qualifier and optional kernel qualifiers, which<br>
> require storing <typen> and X, Y, Z values. (I don't even want to think how<br>
> one would mangle the optional qualifiers into a kernel name and then<br>
> demangle.)<br>
><br>
> That's why we propose to use metadata for this purpose.  Does anyone have a<br>
> better idea?<br>
<br>
I agree that metadata should be used for function qualifiers;<br>
a prerequisite being support for non-discardable function-level<br>
metadata, which would need to be added to LLVM.  I'm undecided on<br>
whether __kernel should also be represented by metadata; there is<br>
precedent (PTX backend) for using the calling convention.<br></blockquote><div><br></div><div>Being discardable is a design point of metadata. You might add something else to support this, but it won't be metadata.</div>

<div><br></div><div>Why are you trying to preserve "kernel"-ness into the LLVM IR? What semantics does it have? What does __kernel actually mean to the optimizers and code generator?</div><div><br></div><div>Could you just make __kernel mean "externally visible" and undecorated functions be "linkonce_odr"? If that's not enough, could you swing it around and maintain single named metadata node with <meta http-equiv="content-type" content="text/html; charset=utf-8">a list of functions that are marked __kernel?</div>

<div><br></div><div>Nick</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I do have a concern though with the semantics of the inliner when it<br>

needs to inline a function with metadata.  One possibility would be to<br>
discard the callee's metadata, or somehow merge it with the caller's.<br>
Discarding seems like the right solution for OpenCL and a good starting<br>
point (in future we may wish to add attributes to metadata nodes like<br>
the 'appending' linkage for globals) but sounds like something that<br>
should be discussed first.<br></blockquote><div><br></div></div>