https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83925

            Bug ID: 83925
           Summary: [SPARC/Solaris] __int128 aligned(8) as function
                    argument is passed in wrong register
           Product: gcc
           Version: 5.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: polyakova.marina69 at gmail dot com
  Target Milestone: ---

Created attachment 43170
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43170&action=edit
preprocessed file for PG_ALIGN_128=8

If we define a new type int128a as __int128 __attribute__((aligned(8))), and
you pass it as not the first function argument, its value in the function may
be incorrect. See the output of the test program:

$ gcc -D PG_ALIGN_128=8 -m64 -o int128test2 int128test2.c
$ ./int128test2
basic aritmetic OK
pass int 16 FAILED
pass uint 16 FAILED
pass int 32 FAILED
pass int 64 FAILED
pass int 128 OK

(see its preprocessed file int128test2_8.i as an attachment)

When the alignment is 16, everything is fine:

$ gcc -D PG_ALIGN_128=16 -m64 -o int128test2 int128test2.c
$ ./int128test2
basic aritmetic OK
pass int 16 OK
pass uint 16 OK
pass int 32 OK
pass int 64 OK
pass int 128 OK

As it turns out, Sparc GCC passes function arguments via register ring which is
referenced as %on in the calling code and as %in in function. And somehow it
happens that alignment attribute of typedef affects access to arguments in the
function, but doesn't affect how regiser ring is filled before call.

the system type: sparc-sun-solaris2.10

the options given when GCC was configured/built:
/home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/configure
--prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin
--sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec --datadir=/opt/csw/share
--sysconfdir=/etc/opt/csw --sharedstatedir=/opt/csw/share
--localstatedir=/var/opt/csw --libdir=/opt/csw/lib
--infodir=/opt/csw/share/info --includedir=/opt/csw/include
--mandir=/opt/csw/share/man --enable-cloog-backend=isl --enable-java-awt=xlib
--enable-languages=ada,c,c++,fortran,go,java,objc --enable-libada
--enable-libssp --enable-nls --enable-objc-gc --enable-threads=posix
--program-suffix=-5.5 --with-cloog=/opt/csw --with-gmp=/opt/csw
--with-included-gettext --with-ld=/usr/ccs/bin/ld --without-gnu-ld
--with-libiconv-prefix=/opt/csw --with-mpfr=/opt/csw --with-ppl=/opt/csw
--with-system-zlib=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-as

Reply via email to