Alloca always returns a pointer in alloca address space, which may
be different from the type defined by the language. For example,
in C++ the auto variables are in the default address space. Therefore
cast alloca to the expected address space when necessary.
Depends on https://reviews.llvm.org/D32977
Do you need to check this? I thought your change doesn't affect OpenCL because alloca AS == private AS in OpenCL and constant AS local objects are treated as private const objects anyways.