alloca instructions always return pointers to the stack / alloca address space. This composes poorly with most HLLs which are address space agnostic and thus have all pointers point to generic/flat. Static allocas were already handled on the AST level, in the implementation of the CreateTempAlloca family of functions, however dynamic allocas were not, which would make the following valid C++ code:
const char* p = static_cast<const char*>(__builtin_alloca(42));
lead to subtly incorrect IR / an assert flaring. This patch addresses that by inserting an address space cast iff the alloca address space is different from generic.