Perhaps "compatibility" is the wrong term to use here.  For now, I would like to "match" what the vendor compiler does.  I don't think using preferred alignment would hurt anything in terms of correctness, but I need to go through the entire back-end to see what effects it could have on performance (e.g. adding extra padding increases local memory usage).  It could be a complete non-issue for all I know right now.<div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Nov 10, 2012 at 1:37 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 Justin,<div class="im"><br>
<br>
On 09/11/12 22:49, Justin Holewinski wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Test cases exist under test/CodeGen/NVPTX (name changed in May).<br>
</blockquote>
<br></div>
I've deleted the empty PTX directory.<div class="im"><br>
<br>
  Now that I'm<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
back at NVIDIA, I'm going to be running through the bugzilla issues (thanks<br>
Dmitry for the reports!).  I have practically the exact same patch here in my<br>
queue. :)<br>
<br>
In this case, I would prefer ABI alignment for compatibility with the vendor<br>
compiler.<br>
</blockquote>
<br></div>
I don't really understand this argument.  If the vendor compiler is aligning to<br>
4 (say) then some globals will have address a multiple of 4, some will have<br>
address a multiple of 8, some will have address a multiple of 16 etc, depending<br>
on the accidents of just where in memory they happen to be placed.  For<br>
example, if you have two 4 byte globals that follow each other in memory, and<br>
that are 4 byte aligned, then if the first one has address a multiple of 4 then<br>
the second will have address a multiple of 8.  In short lots of variables will<br>
be 8 byte aligned by accident.  If LLVM gives them all an alignment of 8, what<br>
does that change?  OK, I will now admit that there is an effect if assumptions<br>
are being made about globals being placed next to each other: if you declare<br>
two globals A and B immediately after each other in the IR then the LLVM<br>
semantics doesn't guarantee that they will be laid out one immediately after<br>
the other in memory.  But that's how it happens in practice so maybe people<br>
are (wrongly) relying on that.  Bumping up the alignment to a multiple of 8<br>
may add extra padding between A and B, causing B to not be at the position that<br>
such naughty people are expecting.<div class="im"><br>
<br>
  It should work either way, but I do need to audit the codebase and<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
tie up any issues here.<br>
</blockquote>
<br></div>
The IR optimizers already bump the alignment of some globals up to the<br>
preferred alignment, check out enforceKnownAlignment in Local.cpp (it ends<br>
up being called from instcombine).<br>
<br>
Ciao, Duncan.<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>
</div>