[PATCH] D32248: CodeGen: Cast alloca to expected address space

Tony Tye via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 15 11:17:57 PDT 2017


t-tye added inline comments.


================
Comment at: lib/CodeGen/CGDecl.cpp:1115
+  assert(T.getAddressSpace() == LangAS::Default ||
+         T.getQualifiers().hasTargetSpecificAddressSpace());
+  auto Addr = getTargetHooks().performAddrSpaceCast(*this,
----------------
Should allowing specifying an address space on a function local automatic variable in OpenCL be allowed? It seems generating LLVM IR that allocates the variable in the alloca address space then address space casting the pointer to some other address space is not what such a language feature is requesting.

It seems it is really requesting that the variable is allocated in a different address space. That could be indicated by putting a different address space on the alloca itself, but the builder only allows an alloca to use the default alloca address space. No target supports this ability.

So maybe the best solution is to make OpenCL be the same as C and not allow an address space qualifier on function scope automatic variables.

If that is done then this assert will only allow the language default address space.


https://reviews.llvm.org/D32248





More information about the cfe-commits mailing list