[cfe-dev] Clang and OpenCL address spaces
John McCall
rjmccall at apple.com
Tue Oct 19 10:40:20 PDT 2010
On Oct 19, 2010, at 10:15 AM, Peter Collingbourne wrote:
> To a certain extent I agree. But then again the storage class seems
> to be a Clang-level implementation detail (storage classes other than
> 'typedef' are not supported in OpenCL). If one accesses a variable
> outside its lifetime then that is undefined behaviour, so any lifetime
> restrictions seem like a lower bound rather than an upper bound.
> The spec also forbids __local variables from being initialised,
> as well as recursion, so the semantics seem to be the same.
>
> I suppose the real differences arise at the codegen level where the
> storage class makes the difference between a global variable and
> an 'alloca' instruction being emitted, and I don't think 'alloca'
> supports address spaces (maybe it should?).
The call stack is always in the generic address space, so I don't know
how 'alloca' could possibly support address spaces.
I guess the $64,000 question is how you're planning on emitting these
in IR. If you're going to emit them as globals and then rewrite all the
references in a later pass, then 'static' seems fine.
John.
More information about the cfe-dev
mailing list