There is an incoming change in LLVM allowing alloca to return a private pointer which does not pointing to address space 0:
https://reviews.llvm.org/D31042
After this change is committed, alloca will return a pointer pointing to an address space specified by the data layout (so called alloca addr space, which is the last component of the data layout, e.g. A5 indicating alloca address space is 5). A data layout not specifying alloca address space will assume it is 0, therefore keeping the original behaviour.
Clang codegen needs to make corresponding changes to account for the API change of alloca. The change is straightforward. Basically when creating alloca, use the alloca address space specified by the data layout.
For OpenCL, the private address space qualifier is 0 in AST. Before this change, 0 address space qualifier is always mapped to target address space 0. As now target private address space is specified by alloca address space in data layout, address space qualifier 0 needs to be mapped to alloca addr space specified by the data layout.
This change has no impact on targets whose alloca addr space is 0.
This change depends on
Should this be >= since it wants to return for all target address spaces, and target_first is the first one?