<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60005>60005</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Broken behavior with target attribute and enqueued blocks
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:codegen,
            OpenCL,
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          arsenm
      </td>
    </tr>
</table>

<pre>
    It's not clear to me what the behavior of the target attribute is supposed to be with enqueued blocks, but what it does now is broken and inconsistent. 

```
__attribute__((target("s-memtime-inst")))
kernel void test_target_features_kernel(global int *i) {
  queue_t default_queue;
 unsigned flags = 0;
  ndrange_t ndrange;

 __builtin_amdgcn_s_memtime();

  enqueue_kernel(default_queue, flags, ndrange,
                 ^(void) {
 __builtin_amdgcn_s_memtime();
                 });
}

```
This program is currently accepted. If I remove the target attribute from the kernel, the builtin use in the kernel code is correctly rejected. The builtin use in the block is never diagnosed. If you attempt to apply the target attribute to the block, it's disallowed. So either one of these must be true:

1. The target attribute should propagate to the block, in which case the implied target-features entries should propagate to the block in the IR
2. If the target attribute is not implied on the block, the target attribute should probably be allowed on the block itself.

The diagnostics for the builtin in the block are missing in either case
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVV1v6zYM_TXyC9HAUeJ8PPihN1mAAgMGbPfdkC3a1ipLnkQlyL8fJDtN02YXC4xYAkWewyOSFt6rziCWrPjBimMmAvXWlcJ5NENWW3kt34jxrQdjCRqNwgFZGBAuvSCgHqHGXpyVdWDbtCfhOiQQRE7VgRCUBx_G0XqU0bdGuCjqAc0_AQNKqLVt3j3jB6gDTXEVgbQYQS_RvXb2HQ0II0GZxhqvPKGhBbD8yPLX-X-Tz0_aVtUHg6pifMf4bmKW1ty_DDiQGvBFGU-Mc8b385Pc39EZ1HC2SgKhp2pyrloUFBz6ajrA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