Test cases exist under test/CodeGen/NVPTX (name changed in May).  Now that I'm back at NVIDIA, I'm going to be running through the bugzilla issues (thanks Dmitry for the reports!).  I have practically the exact same patch here in my queue. :)<div>
<br></div><div>In this case, I would prefer ABI alignment for compatibility with the vendor compiler.  It should work either way, but I do need to audit the codebase and tie up any issues here.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Nov 9, 2012 at 5:23 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Dmitry,<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You're right, global variables use preferred alignment. And - yes,<br>
preferred alignment in this case is bigger: 8 instead of 4. NVIDIA's<br>
prop. compiler gives 4. However, since CUDA 5.0 ptx modules are<br>
linkable with each other, I think alignments for externally visible<br>
functions and data should all follow ABI rules.<br>
</blockquote>
<br></div>
giving it an alignment of 8 does follow ABI rules: everything that is<br>
8 byte aligned has an address that is a multiple of 4, i.e. it is also<br>
4 byte aligned.<br>
<br>
It would be wrong to assume that external globals have the preferred<br>
alignment: they can only be assumed to have the ABI alignment.  But<br>
as we are aligning this variable we can give it the alignment we like<br>
as long as it is at least 4.<br>
<br>
In short, I think using the preferred alignment is correct in this<br>
context.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there a guide on making tests? I have ~5 pending patches never<br>
accepted simply because I'm not familiar with LLVM test system :-/<br>
</blockquote>
<br></div>
Your test would go in test/CodeGen/PTX/.  It should use FileCheck,<br>
take a look at test/CodeGen/X86/zext-trunc.ll for an example.  As<br>
there are no PTX tests at all for the moment, you need to create a<br>
lit.local.cfg file in PTX/.  Imitate the X86 one.<br>
<br>
Ciao, Duncan.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- D.<br>
<br>
2012/11/9 Duncan Sands <<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Dmitry,<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm attaching a patch that should fix the issue mentioned above. It<br>
<br>
simply makes the same check seen in the same file for global<br>
variables:<br>
<br>
    emitPTXAddressSpace(PTy-><u></u>getAddressSpace(), O);<br>
    if (GVar->getAlignment() == 0)<br>
      O << " .align " << (int) TD->getPrefTypeAlignment(ETy);<br>
    else<br>
      O << " .align " << GVar->getAlignment();<br>
</blockquote>
<br>
<br>
it's not quite the same because your patch uses the ABI alignment, while<br>
in this snippet it is the preferred alignment (which is usually the same<br>
as the ABI alignment, but may be bigger).<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Could you please review and commit? Do you think it needs a test case?<br>
</blockquote>
<br>
<br>
Yes, it needs a testcase.<br>
<br>
Ciao, Duncan.<br>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></blockquote>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>
</div>