bader added inline comments.
================ Comment at: clang/lib/CodeGen/CGExpr.cpp:4554 + + // Language rules define if it is legal to cast from one address space + // to another, and which address space we should use as a "common ---------------- asavonic wrote: > sdmitriev wrote: > > bader wrote: > > > Anastasia wrote: > > > > What language rules? > > > I suppose it's a generic note and author didn't meant some particular > > > language here. This change was contributed by @sdmitriev. > > > @sdmitriev, could you clarify, please? > > This comment was originally added by @asavonic to > > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and > > later I reused his code along with the comment in this file while fixing a > > very similar issue. So, I guess it would be more correct to ask Andrew to > > clarify. @asavonic, can you please comment on this? > > This comment was originally added by @asavonic to > > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and > > later I reused his code along with the comment in this file while fixing a > > very similar issue. > > There is `if (Opts.SYCLIsDevice)` In CGExprScalar.cpp, so we handle SYCL > language rules. > In SYCL, (almost) all pointers have default address space in AST, but in CG > some pointers become private/local/global, and some are lowered as generic > pointers. We need to add an implicit addrspacecast in CG to emit an > expression that expects the same type for its operands. > > For example: > const char *str = ... ; > const char *phi_str = i > 2 ? str : "hello world!"; > > In AST types of `str` and `"hello world"` are the same (`const char *`). In > CG we emit `str` as `i8 addrspace(4)*` and `"hello world"` as `i8*`. At this > point we have to decide what type `phi_str` should have, and addrspacecast > the operands accordingly. Is it possible to avoid fixing address space mismatch at this point by adjusting AST as suggested by John in this comment: https://reviews.llvm.org/D89909#inline-837495? I wonder if it can be done w/o impacting C++ template metaprogramming as noted in this thread: http://clang-developers.42468.n3.nabble.com/RFC-Re-use-OpenCL-address-space-attributes-for-SYCL-td4068754.html. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D89909/new/ https://reviews.llvm.org/D89909 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits