[SYCL][FE] Attributes from any function are propagated to the kernel contrary to the intent
- Dominant language
- LLVM
- Stars
- 1.5k
- Forks
- 854
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 137
Description
https://github.com/intel/llvm/blob/88e56d9a3073253d9922c409aca61f3fdf0d34a7/clang/lib/Sema/SemaSYCL.cpp#L415:
```
// Allow the following kernel attributes only on lambda functions and
// function objects that are called directly from a kernel (i.e. the one
// passed to the parallel_for function). For all other cases,
// emit a warning and ignore.
```
In fact attributes are propagated from any function called from within a kernel, and are other functions called in some cases.
To see the issue, compile this source
[attr-prop.txt](https://github.com/intel/llvm/files/4727464/attr-prop.txt)
`clang++ -fsycl -fsycl-device-only -Xclang -emit-llvm -o - -c attr-prop.cpp`
and note the line:
`define dso_local spir_kernel void @_ZTSZ11invoke_foo2vE10KernelName() #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !4 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !4 !no_global_work_offset !4 {`
`no_global_work_offset` got propagated from unrelated function w/o warning.
Contributor guide
Assessment
This issue has not been assessed yet.