<div dir="ltr"><div class="gmail_default" style="font-size:small">Arriving late to this thread, but to add what others have said: reordering or sorting data items based on alignment is straightforward to do in a linker plugin. An example can be found in this test (part of gold linker test suite):</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gold/testsuite/plugin_layout_with_alignment.sh;h=c5f07aec287e87de955dd924efefabd56e8d6213;hb=HEAD">https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gold/testsuite/plugin_layout_with_alignment.sh;h=c5f07aec287e87de955dd924efefabd56e8d6213;hb=HEAD</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">The source for the plugin is at </div><div class="gmail_default"><br></div><div class="gmail_default"><a href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gold/testsuite/plugin_section_alignment.cc;h=6f64bdc6e8687bc5cfb61109503844d9608ee757;hb=HEAD">https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gold/testsuite/plugin_section_alignment.cc;h=6f64bdc6e8687bc5cfb61109503844d9608ee757;hb=HEAD</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">Than</div><div class="gmail_default"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 26, 2016 at 12:54 PM, Mehdi Amini via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jul 26, 2016, at 8:46 AM, Abe Skolnik <<a href="mailto:a.skolnik@samsung.com">a.skolnik@samsung.com</a>> wrote:<br>
><br>
>>> My question this time is this: is re-ordering globals at the LLVM level both possible [...]<br>
><br>
> On 07/25/2016 10:53 PM, Mehdi Amini wrote:<br>
><br>
>> Isn’t something a linker could/should do?<br>
><br>
> AFAIK & TTBOMK, a compiler should do it [if allowed by the language]<br>
<br>
</span>Compiler only see one translation unit at a time, the linker sees multiple, it is not clear to me why you are thinking the compiler should handle it?<br>
<span class=""><br>
> and a linker should not mess it up.  I don`t know that a linker is allowed to make assumptions about code not traversing labels in its data accesses.  After all, a compiler may have assigned labels to e.g. the start of a "struct" instance and to a specific part of that same struct.  That doesn`t mean the linker is free to move the middle of the struct somewhere else far from the start of the struct.<br>
><br>
> IOW, a linker is required to handle the code no matter what the source language was and what its specification says about implementations being allowed to re-order things and whether or not the language allows the programmer to _validly_ assume that when two arrays of identical element type are created back-to-back, the second array immediately follows the first, thus effectively creating a single array with its element count being the sum of the two element counts of the as-written arrays.<br>
><br>
><br>
><br>
> On 07/25/2016 10:53 PM, Mehdi Amini wrote:<br>
><br>
>> Such programming language should not use LLVM global variables if they need to provide such guarantee,<br>
>> but probably use instead something more like a global array when lowering to LLVM IR.<br>
><br>
> Agreed, but I can`t [en]force that.  That would need to be decided by the LLVM steering committee or something like that, then documented publicly.<br>
<br>
</span>I’m saying that it is *already* the current state of affairs, AFAIK we don’t provide any guarantee about what you describes.<br>
<br>
—<br>
Mehdi<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>