public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38496]  New: Gcc misaligns arrays when stack is forced follow the x8632 ABI
@ 2008-12-11 22:54 whaley at cs dot utsa dot edu
  2008-12-11 23:05 ` [Bug target/38496] " pinskia at gcc dot gnu dot org
                   ` (25 more replies)
  0 siblings, 26 replies; 29+ messages in thread
From: whaley at cs dot utsa dot edu @ 2008-12-11 22:54 UTC (permalink / raw)
  To: gcc-bugs

I notice that gcc does not follow the 32-bit ABI for the x86, in that it forces
the stack alignment to 16 bytes rather than the ABI-required 4 bytes.  This is
a problem when interacting with compilers that are ABI-compliant.

So, I threw the -mpreferred-stack-boundary=2 on gcc/gfortran/g77 to restore ABI
compliance, and then I notice that gfortran/g77 generates double precision
arrays that are not aligned to 8-byte boundaries, which breaks pretty much all
interoperability as well (and also means you will get cache splits all the
time, and so decrease your performance).  The -malign-double flag does not fix
this.  So I now have the choice of not interoperating due to ABI violation, or
not interoperating with other compilers due to lack of data alignment.

I read the gcc manual on this point, and it talks like you have to choose:
either you force the stack to always be aligned to 16-byte boundary, or gcc is
unable to guarantee alignment for any stack value.  However, this is a false
choice: given an unaligned stack it is trivial for a function to force a
particular alignment (eg., 16-byte) for some values it is storing on the stack.
 I can provide code and pointers, if that is helpful.

So, I think it is a bad idea for gcc to violate the ABI for something that is
trivial to do without violating the ABI: not only do you rule out
interoperability by not following the ABI, but even in strict gcc code, you
lose a lot of performance when people need to follow the ABI.

However, if the preferred stack trick worked, I could work around, but since it
actually makes arrays not be aligned to a multiple of their base size, I cannot
find a workaround for this misfeature.  Any ideas?

Thanks,
Clint


-- 
           Summary: Gcc misaligns arrays when stack is forced follow the
                    x8632 ABI
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: whaley at cs dot utsa dot edu


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


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2014-02-16 13:12 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-38496-4@http.gcc.gnu.org/bugzilla/>
2014-02-16 13:12 ` [Bug target/38496] Gcc misaligns arrays when stack is forced follow the x8632 ABI jackie.rosen at hushmail dot com
2008-12-11 22:54 [Bug fortran/38496] New: " whaley at cs dot utsa dot edu
2008-12-11 23:05 ` [Bug target/38496] " pinskia at gcc dot gnu dot org
2008-12-11 23:06 ` pinskia at gcc dot gnu dot org
2008-12-11 23:26 ` whaley at cs dot utsa dot edu
2008-12-11 23:29 ` pinskia at gcc dot gnu dot org
2008-12-11 23:44 ` whaley at cs dot utsa dot edu
2008-12-12  0:02 ` joseph at codesourcery dot com
2008-12-12  0:53 ` whaley at cs dot utsa dot edu
2008-12-12  1:06 ` hjl dot tools at gmail dot com
2008-12-12  1:26 ` joseph at codesourcery dot com
2008-12-12  1:50 ` whaley at cs dot utsa dot edu
2008-12-15  0:23 ` joseph at codesourcery dot com
2008-12-15 14:54 ` whaley at cs dot utsa dot edu
2008-12-15 18:19 ` joseph at codesourcery dot com
2008-12-15 21:34 ` whaley at cs dot utsa dot edu
2008-12-15 21:39   ` Andrew Thomas Pinski
2008-12-15 21:40 ` pinskia at gmail dot com
2008-12-15 22:03 ` whaley at cs dot utsa dot edu
2008-12-15 23:02   ` Andrew Pinski
2008-12-15 23:03 ` pinskia at gmail dot com
2008-12-15 23:40 ` whaley at cs dot utsa dot edu
2008-12-16  0:10 ` joseph at codesourcery dot com
2009-03-18 13:25 ` sliwa at cft dot edu dot pl
2009-07-23 13:14 ` jakub at gcc dot gnu dot org
2009-07-23 14:35 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-24 12:16 ` rguenth at gcc dot gnu dot org
2009-07-24 17:05 ` whaley at cs dot utsa dot edu
2009-07-31  1:18 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-10-23  9:45 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).