This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix yet another ABI problem on SPARC64


Found by visual inspection: TI mode integers are not aligned on a 16-byte 
boundary (their base alignment) in the parameter slot.  Now the va_arg 
handling code expects them to be 16-byte aligned, so that the attached 
testcase fails.

Fixed by mimicing what is done for TFmode.  Compiled, regtested and 
compat-regtested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.7.

Applied to mainline and 3.4 branch.  I've also updated sparc-abi.html.


2004-02-02  Eric Botcazou  <ebotcazou@libertysurf.fr>

	* config/sparc/sparc.c (function_arg_slotno): Align TImode
	arguments on a 16-byte boundary in the parameter array if ARCH64.
	Split handling of TFmode.


2004-02-02  Eric Botcazou  <ebotcazou@libertysurf.fr>

	* gcc.dg/titype-1.c: New test.


-- 
Eric Botcazou
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.271.4.9
diff -u -p -r1.271.4.9 sparc.c
--- config/sparc/sparc.c	27 Jan 2004 14:45:19 -0000	1.271.4.9
+++ config/sparc/sparc.c	2 Feb 2004 10:12:48 -0000
@@ -4890,19 +4890,27 @@ function_arg_slotno (const struct sparc_
 	 See emit_call_1.  */
       return -1;
 
+    case TImode : case CTImode :
+      if (TARGET_ARCH64 && (slotno & 1) != 0)
+	slotno++, *ppadding = 1;
+      /* fallthrough */
+
     case QImode : case CQImode :
     case HImode : case CHImode :
     case SImode : case CSImode :
     case DImode : case CDImode :
-    case TImode : case CTImode :
       if (slotno >= SPARC_INT_ARG_MAX)
 	return -1;
       regno = regbase + slotno;
       break;
 
+    case TFmode : case TCmode :
+      if (TARGET_ARCH64 && (slotno & 1) != 0)
+	slotno++, *ppadding = 1;
+      /* fallthrough */
+
     case SFmode : case SCmode :
     case DFmode : case DCmode :
-    case TFmode : case TCmode :
       if (TARGET_ARCH32)
 	{
 	  if (slotno >= SPARC_INT_ARG_MAX)
@@ -4911,9 +4919,6 @@ function_arg_slotno (const struct sparc_
 	}
       else
 	{
-	  if ((mode == TFmode || mode == TCmode)
-	      && (slotno & 1) != 0)
-	    slotno++, *ppadding = 1;
 	  if (TARGET_FPU && named)
 	    {
 	      if (slotno >= SPARC_FP_ARG_MAX)
/* { dg-do compile } */

/* Not all platforms support TImode integers.  */
#if defined(__LP64__) || defined(__sparc__)
typedef int TItype __attribute__ ((mode (TI)));  /* { dg-error "no data type for mode" "TI" { target sparc-sun-solaris2.[0-6]* } } */
#else
typedef long TItype;
#endif

#include <stdarg.h>

extern void abort(void);


void foo(int i, ...)
{
  TItype q;
  va_list va;

  va_start(va, i);
  q = va_arg(va, TItype);
  va_end(va);

  if (q != 5)
    abort();
}

int main(void)
{
  TItype q = 5;

  foo(1, q);
  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]