------- Comment #23 from mikulas at artax dot karlin dot mff dot cuni dot cz  
2009-07-23 14:34 -------
So, Joseph is basically arguing that it doesn't make sense to follow bad
standards. Fine. So let's ignore the "i386 ABI standard" thing for a moment a
look at the change from the practical point of view:

--- If we assume 16-bit stack alignment, who gets the advantage?

* some scientists doing number crunching, it will save stack realign. Most
desktop applications don't use SSE heavily (or not at all). Maybe video players
(most of them have sse in assembler though and don't rely on gcc for sse
generation).

--- If we assume 16-bit stack alignment, what problems will it bring?

* anything called from an inline assembler will have a possibility to fail.
Assembler programmers don't know about this alignment requirement and have been
writing "pushl $0; pushl $1; call function; addl $8, %esp" for ages.

* anything compiled by Intel CC, TCC or other compilers.
Intel CC assumes 4-byte alignment and uses some algorithm to realign only at
certain points (if the function can be only called from stack-aligned
functions, it doesn't have to have the stack realigned). If Intel CC does only
integer arithmetics, it aligns the stack only for 4 bytes.
Intel CC-generated code calls glibc that is being compiled by gcc, so failures
will come from there.

* anything autogenerated (java, dosbox, qemu, firefox 3.5...)

* anything compiled with gcc 2.95.* and earlier.

The worst thing about these failures is that they'll happen only very
sporadically, gcc autovectorizer doesn't generate vector functions in most of
the glibc, so most of the code will be seemingly unaffected. If at random place
in some library gcc vectorizes something and that random place will be called
from any of the above code, the crash will happen. So you'll get crashes at
random points.

To turn these random crashes into deterministic crashes, I suggest to try this.
Hack gcc to generate test $15, %esp; jnz abort at the beginning of every
function. Compile the whole Linux distribution with this gcc. Test it
(including various 3rd party Linux program). If it works, come back later to
this debate and propose how stacks should be 16-byte aligned.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38496

Reply via email to