On Wed, 17 Jan 2018 18:02:26 +0300
Marina Polyakova <m.polyak...@postgrespro.ru> wrote:


> > Attached is a possible test program.  I can confirm it passes on a
> > machine with working __int128, but I have no idea whether it will
> > detect the problem on yours.  If not, maybe you can tweak it?
> 
> Thank you! Using gcc 5.5.0 it prints that everything is ok. But, 
> investigating the regression diffs, we found out that the error
> occurs when we pass int128 as not the first argument to the function
> (perhaps its value is replaced by the value of some address):

I'm attaching stripped-down version of test program, which demonstrate
the problem and two assembler listings produced with this C source using
alignment 8 and 16. May be this stripped-down version can be used as 
base for configure test.

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. Looks like bug in GCC.

Unfortunately, we have only one Sparc machine and started our
investigation by upgrading GCC 5.2.0 to GCC 5.5.0, so it is hard to
downgrade and test with older GCC.

--
#include <stddef.h>
#include <stdio.h>


# ifndef PG_ALIGN_128
#define PG_ALIGN_128 8
# endif

/* GCC, Sunpro and XLC support aligned */
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#endif

typedef __int128 int128a
#if defined(pg_attribute_aligned)
pg_attribute_aligned(PG_ALIGN_128)
#endif
;
int128a holder;
void pass_by_val(void *buffer,int128a par) {
   holder=par;
}




int
main()
{
	long int i64 = 97656225L << 12;
	int128a q;	
	pass_by_val(main,(int128a) i64);
	q=(int128a) i64;
	printf("pass int 64 %s\n",(q==holder)?"OK":"FAILED");	
	if (q!=holder)
		return 1;
	return 0;
}

Attachment: align_test8.s
Description: Binary data

Attachment: align_test16.s
Description: Binary data

Reply via email to