<div dir="ltr">Richard,<div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 15, 2016 at 5:32 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Jan 15, 2016 at 5:29 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> On Fri, Jan 15, 2016 at 4:22 PM, Artem Belevich <<a href="mailto:tra@google.com">tra@google.com</a>> wrote:<br>
>> tra added inline comments.<br>
>><br>
>> ================<br>
>> Comment at: lib/CodeGen/CodeGenModule.cpp:2334<br>
>> @@ -2339,1 +2333,3 @@<br>
>> +      D->hasAttr<CUDASharedAttr>())<br>
>>      Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));<br>
>> +  else if (!InitExpr) {<br>
>> ----------------<br>
>> rsmith wrote:<br>
>>> As this is a global variable, it should presumably still be statically zero-initialized.<br>
>> There is no way to initialize __shared__ variables. They are rough equivalent of local variables, only in this case CUDA allocates them per kernel invocation from a shared buffer with no guarantees regarding its contents.<br>
>><br>
>> They used to be zero-initialized by compiler, but that was intentionally changed to undef in r245786 / <a href="http://reviews.llvm.org/D12241" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12241</a><br>
><br>
> That doesn't seem right. C++ guarantees zero-initialization for all<br>
> globals, prior to performing any other initialization.<br>
<br>
</div></div>It looks like the problem being fixed by D12241 was probably caused by<br>
the __shared__ variables having the wrong linkage.<br>
</blockquote></div><div class="gmail_extra"><br></div><div class="gmail_extra">I'll take a look at this separately as it's unrelated to this patch.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I believe current patch addresses your other comments. </div><div class="gmail_extra"><br></div><div class="gmail_extra">--Artem</div><div class="gmail_extra"><br></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">--Artem Belevich</div></div>
</div></div></div>