Trailing return yields wrong CPU code.
Created by: vchuravy
The return
statement causes incorrect code.
julia> @macroexpand @kernel function f()
return nothing
end
yields:
function cpu_f(; )
$(Expr(:aliasscope))
for var"##I#422" = (KernelAbstractions.__workitems_iterspace)()
#= /home/vchuravy/src/KernelAbstractions/src/macros.jl:211 =#
(KernelAbstractions.__validindex)(var"##I#422") || continue
#= /home/vchuravy/src/KernelAbstractions/src/macros.jl:212 =#
#= /home/vchuravy/src/KernelAbstractions/src/macros.jl:213 =#
return nothing
end
$(Expr(:popaliasscope))
return nothing
end
Which means that we will not execute more than the first iteration. Probably we should forbid return
entirely.