[PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 20 07:59:45 PDT 2016
yaxunl added inline comments.
================
Comment at: lib/Sema/SemaInit.cpp:6945
@@ +6944,3 @@
+ // get the integer literal.
+ Init = cast<ImplicitCastExpr>(const_cast<Expr*>(
+ Var->getInit()))->getSubExpr();
----------------
Anastasia wrote:
> What if global variable sampler is initialized with another sampler variable:
> sampler_t s1 = ...;
> sampler_t s2 = s1;
> ...
> foo(s2);
>
> Btw, I am wondering whether this code is needed at all, because I am guessing variable initialization will be handled separately anyways, irrespective to whether it's being used in a call or not...
clang currently does not allow assigning a sampler global variable with another sampler global variable. An error will be emitted:
initializer element is not a compile-time constant
We could allow this, but I think allowing this is not a very useful feature, so I would recommend continue not allowing it.
If we do not replace references of function-scope sampler variable with its initializer here, we will end up with a global variable initialized with an integer and we will not be able to do codegen for it as in LLVM we cannot initialize a global variable with a function call.
https://reviews.llvm.org/D21567
More information about the cfe-commits
mailing list