[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#711558: gcc-4.8: [m68k] patch set 2



tags 711558 + patch
thanks

Hi,

this should do the trick, already tested the bugfix with
a cross-compiler.

Building src:gcc-4.8 on wheezy needs the -d dpkg-buildpackage
option though because the libcloog-isl-dev version is not
lowered down to 0.17 in wheezy (it does build and work with
-d though). Just in case you want to fix that, too.

bye,
//mirabilos
-- 
> emacs als auch vi zum Kotzen finde (joe rules) und pine für den einzig
> bedienbaren textmode-mailclient halte (und ich hab sie alle ausprobiert). ;)
Hallooooo, ich bin der Holger ("Hallo Holger!"), und ich bin ebenfalls
... pine-User, und das auch noch gewohnheitsmäßig ("Oooooooohhh").  [aus dasr]
diff -u gcc-4.8-4.8.1/debian/changelog gcc-4.8-4.8.1/debian/changelog
--- gcc-4.8-4.8.1/debian/changelog
+++ gcc-4.8-4.8.1/debian/changelog
@@ -1,3 +1,21 @@
+gcc-4.8 (4.8.1-9+m68k.2) unreleased; urgency=low
+
+  * Use -fno-auto-inc-dec for pr52306 (from Mikael Pettersson)
+
+ -- Thorsten Glaser <tg@mirbsd.de>  Sat, 17 Aug 2013 21:08:30 +0200
+
+gcc-4.8 (4.8.1-9+m68k.1) unreleased; urgency=high
+
+  * Merge several old m68k-specific patches from gcc-4.6 package:
+    - libffi-m68k: rebased against gcc-4.8 and libffi 3.0.13-4
+    - m68k-revert-pr45144: needed for Ada
+    - pr52306-retry-hack: workaround for ICE in cselib_record_set
+    - pr52714: revert optimisation that breaks CC0 arch
+  * Apply patch from Mikael Pettersson to fix PR49847.
+  * (Closes: #711558)
+
+ -- Thorsten Glaser <tg@mirbsd.de>  Sat, 17 Aug 2013 18:12:36 +0000
+
 gcc-4.8 (4.8.1-9) unstable; urgency=low
 
   * Update to SVN 20130815 (r201764) from the gcc-4_8-branch.
diff -u gcc-4.8-4.8.1/debian/rules.patch gcc-4.8-4.8.1/debian/rules.patch
--- gcc-4.8-4.8.1/debian/rules.patch
+++ gcc-4.8-4.8.1/debian/rules.patch
@@ -80,6 +80,8 @@
 	kfreebsd-unwind \
 	libgcc-no-limits-h \
 	kfreebsd-boehm-gc \
+	pr49847 \
+	libffi-m68k \
 
 #	$(if $(filter yes, $(DEB_CROSS)),,gcc-print-file-name) \
 #	libstdc++-nothumb-check \
@@ -193,6 +195,8 @@
 
 ifeq ($(DEB_TARGET_ARCH),m68k)
   debian_patches += m68k-ada
+  debian_patches += m68k-revert-pr45144
+  debian_patches += pr52714
 endif
 
 ifeq ($(DEB_TARGET_ARCH),powerpcspe)
@@ -245,6 +249,9 @@
 debian_patches += gcc-ice-hack gcc-ice-apport
 #FIXME
 #debian_patches += gold-and-ld
+ifeq ($(DEB_TARGET_ARCH),m68k)
+  debian_patches += pr52306-retry-hack
+endif
 
 debian_patches += libjava-fixed-symlinks
 debian_patches += libstdc++-arm-wno-abi
only in patch2:
unchanged:
--- gcc-4.8-4.8.1.orig/debian/patches/libffi-m68k.diff
+++ gcc-4.8-4.8.1/debian/patches/libffi-m68k.diff
@@ -0,0 +1,141 @@
+# DP: Apply #660525 fix to in-tree libffi
+
+--- a/src/libffi/src/m68k/sysv.S
++++ b/src/libffi/src/m68k/sysv.S
+@@ -2,9 +2,10 @@
+ 	
+    sysv.S - Copyright (c) 2012 Alan Hourihane
+ 	    Copyright (c) 1998, 2012 Andreas Schwab
+-	    Copyright (c) 2008 Red Hat, Inc. 
+-   
+-   m68k Foreign Function Interface 
++	    Copyright (c) 2008 Red Hat, Inc.
++	    Copyright (c) 2012 Thorsten Glaser
++
++   m68k Foreign Function Interface
+ 
+    Permission is hereby granted, free of charge, to any person obtaining
+    a copy of this software and associated documentation files (the
+@@ -168,8 +169,28 @@ retstruct1:
+ 
+ retstruct2:
+ 	btst	#7,%d2
+-	jbeq	noretval
++	jbeq	retsint8
+ 	move.w	%d0,(%a1)
++	jbra	epilogue
++
++retsint8:
++	btst	#8,%d2
++	jbeq	retsint16
++	| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
++#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
++	ext.w	%d0
++	ext.l	%d0
++#else
++	extb.l	%d0
++#endif
++	move.l	%d0,(%a1)
++	jbra	epilogue
++
++retsint16:
++	btst	#9,%d2
++	jbeq	noretval
++	ext.l	%d0
++	move.l	%d0,(%a1)
+ 
+ noretval:
+ epilogue:
+@@ -201,8 +222,10 @@ CALLFUNC(ffi_closure_SYSV):
+ 	lsr.l	#1,%d0
+ 	jne	1f
+ 	jcc	.Lcls_epilogue
++	| CIF_FLAGS_INT
+ 	move.l	-12(%fp),%d0
+ .Lcls_epilogue:
++	| no CIF_FLAGS_*
+ 	unlk	%fp
+ 	rts
+ 1:
+@@ -210,6 +233,7 @@ CALLFUNC(ffi_closure_SYSV):
+ 	lsr.l	#2,%d0
+ 	jne	1f
+ 	jcs	.Lcls_ret_float
++	| CIF_FLAGS_DINT
+ 	move.l	(%a0)+,%d0
+ 	move.l	(%a0),%d1
+ 	jra	.Lcls_epilogue
+@@ -224,6 +248,7 @@ CALLFUNC(ffi_closure_SYSV):
+ 	lsr.l	#2,%d0
+ 	jne	1f
+ 	jcs	.Lcls_ret_ldouble
++	| CIF_FLAGS_DOUBLE
+ #if defined(__MC68881__) || defined(__HAVE_68881__)
+ 	fmove.d	(%a0),%fp0
+ #else
+@@ -242,17 +267,37 @@ CALLFUNC(ffi_closure_SYSV):
+ 	jra	.Lcls_epilogue
+ 1:
+ 	lsr.l	#2,%d0
+-	jne	.Lcls_ret_struct2
++	jne	1f
+ 	jcs	.Lcls_ret_struct1
++	| CIF_FLAGS_POINTER
+ 	move.l	(%a0),%a0
+ 	move.l	%a0,%d0
+ 	jra	.Lcls_epilogue
+ .Lcls_ret_struct1:
+ 	move.b	(%a0),%d0
+ 	jra	.Lcls_epilogue
+-.Lcls_ret_struct2:
++1:
++	lsr.l	#2,%d0
++	jne	1f
++	jcs	.Lcls_ret_sint8
++	| CIF_FLAGS_STRUCT2
+ 	move.w	(%a0),%d0
+ 	jra	.Lcls_epilogue
++.Lcls_ret_sint8:
++	move.l	(%a0),%d0
++	| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
++#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
++	ext.w	%d0
++	ext.l	%d0
++#else
++	extb.l	%d0
++#endif
++	jra	.Lcls_epilogue
++1:
++	| CIF_FLAGS_SINT16
++	move.l	(%a0),%d0
++	ext.l	%d0
++	jra	.Lcls_epilogue
+ 	CFI_ENDPROC()
+ 
+ 	.size	CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
+--- a/src/libffi/src/m68k/ffi.c
++++ b/src/libffi/src/m68k/ffi.c
+@@ -123,6 +123,8 @@ ffi_prep_args (void *stack, extended_cif
+ #define CIF_FLAGS_POINTER	32
+ #define CIF_FLAGS_STRUCT1	64
+ #define CIF_FLAGS_STRUCT2	128
++#define CIF_FLAGS_SINT8		256
++#define CIF_FLAGS_SINT16	512
+ 
+ /* Perform machine dependent cif processing */
+ ffi_status
+@@ -200,6 +202,14 @@ ffi_prep_cif_machdep (ffi_cif *cif)
+       cif->flags = CIF_FLAGS_DINT;
+       break;
+ 
++    case FFI_TYPE_SINT16:
++      cif->flags = CIF_FLAGS_SINT16;
++      break;
++
++    case FFI_TYPE_SINT8:
++      cif->flags = CIF_FLAGS_SINT8;
++      break;
++
+     default:
+       cif->flags = CIF_FLAGS_INT;
+       break;
only in patch2:
unchanged:
--- gcc-4.8-4.8.1.orig/debian/patches/m68k-revert-pr45144.diff
+++ gcc-4.8-4.8.1/debian/patches/m68k-revert-pr45144.diff
@@ -0,0 +1,18 @@
+[revert the minor PR45144 missed-optimization fix because it
+ results in miscompilation of gnat on m68k with gcc-4.6 and 4.5;
+ with gcc-4.7 other changes mask the issue <mikpe@it.uu.se>]
+
+	PR ada/48835
+
+--- a/src/gcc/tree-sra.c
++++ b/src/gcc/tree-sra.c
+@@ -916,9 +916,6 @@ type_consists_of_records_p (tree type)
+       {
+ 	tree ft = TREE_TYPE (fld);
+ 
+-	if (DECL_BIT_FIELD (fld))
+-	  return false;
+-
+ 	if (!is_gimple_reg_type (ft)
+ 	    && !type_consists_of_records_p (ft))
+ 	  return false;
only in patch2:
unchanged:
--- gcc-4.8-4.8.1.orig/debian/patches/pr49847.diff
+++ gcc-4.8-4.8.1/debian/patches/pr49847.diff
@@ -0,0 +1,28 @@
+gcc/
+
+2012-02-26  Mikael Pettersson  <mikpe@it.uu.se>
+
+	PR rtl-optimization/49847
+	* cse.c (fold_rtx) <case CC0>: If prev_insn_cc0 is zero
+	don't call equiv_constant on it.
+
+--- a/src/gcc/cse.c
++++ b/src/gcc/cse.c
+@@ -3194,9 +3194,14 @@ fold_rtx (rtx x, rtx insn)
+ 
+ #ifdef HAVE_cc0
+ 	  case CC0:
+-	    folded_arg = prev_insn_cc0;
+-	    mode_arg = prev_insn_cc0_mode;
+-	    const_arg = equiv_constant (folded_arg);
++	    if (!prev_insn_cc0)
++	      const_arg = 0;
++	    else
++	      {
++		folded_arg = prev_insn_cc0;
++		mode_arg = prev_insn_cc0_mode;
++		const_arg = equiv_constant (folded_arg);
++	      }
+ 	    break;
+ #endif
+ 
only in patch2:
unchanged:
--- gcc-4.8-4.8.1.orig/debian/patches/pr52306-retry-hack.diff
+++ gcc-4.8-4.8.1/debian/patches/pr52306-retry-hack.diff
@@ -0,0 +1,236 @@
+# DP: retry a known m68k ICE with -fno-auto-inc-dec
+# DP: then with -O1 then -O0 in case it gets better
+
+--- a/src/gcc/diagnostic.c
++++ b/src/gcc/diagnostic.c
+@@ -450,6 +450,12 @@ diagnostic_action_after_output (diagnost
+ 	exit (ICE_EXIT_CODE);
+       }
+ 
++    case DK_TGV:
++      fnotice (stderr, "Retrying with lowered optimisation,\n"
++	       "this is a known bug, do not worry. If it'll\n"
++	       "still fail, just fail the package build.\n");
++      exit (TGV_EXIT_CODE);
++
+     case DK_FATAL:
+       if (context->abort_on_error)
+ 	real_abort ();
+@@ -636,7 +642,7 @@ diagnostic_report_diagnostic (diagnostic
+       /* If we're reporting an ICE in the middle of some other error,
+ 	 try to flush out the previous error, then let this one
+ 	 through.  Don't do this more than once.  */
+-      if (diagnostic->kind == DK_ICE && context->lock == 1)
++      if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_TGV) && context->lock == 1)
+ 	pp_newline_and_flush (context->printer);
+       else
+ 	error_recursion (context);
+@@ -708,7 +714,7 @@ diagnostic_report_diagnostic (diagnostic
+ 
+   context->lock++;
+ 
+-  if (diagnostic->kind == DK_ICE)
++  if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_TGV)
+     {
+ #ifndef ENABLE_CHECKING
+       /* When not checking, ICEs are converted to fatal errors when an
+@@ -721,7 +727,7 @@ diagnostic_report_diagnostic (diagnostic
+ 	  expanded_location s = expand_location (diagnostic->location);
+ 	  fnotice (stderr, "%s:%d: confused by earlier errors, bailing out\n",
+ 		   s.file, s.line);
+-	  exit (ICE_EXIT_CODE);
++	  exit (diagnostic->kind == DK_TGV ? TGV_EXIT_CODE : ICE_EXIT_CODE);
+ 	}
+ #endif
+       if (context->internal_error)
+@@ -1157,3 +1163,17 @@ real_abort (void)
+ {
+   abort ();
+ }
++
++void
++tgv_abort (const char *gmsgid, ...)
++{
++  diagnostic_info diagnostic;
++  va_list ap;
++
++  va_start (ap, gmsgid);
++  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_TGV);
++  report_diagnostic (&diagnostic);
++  va_end (ap);
++
++  gcc_unreachable ();
++}
+--- a/src/gcc/diagnostic.def
++++ b/src/gcc/diagnostic.def
+@@ -43,3 +43,4 @@ prefix does not matter.  */
+ DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ")
+ DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ")
+ 
++DEFINE_DIAGNOSTIC_KIND (DK_TGV, "internal compiler error: ")
+--- a/src/gcc/system.h
++++ b/src/gcc/system.h
+@@ -249,6 +249,7 @@ extern int errno;
+ #endif
+ 
+ #define ICE_EXIT_CODE 4
++#define TGV_EXIT_CODE 23
+ 
+ #ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+@@ -691,6 +692,15 @@ extern void fancy_abort (const char *, i
+ #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
+ #endif
+ 
++extern void tgv_abort (const char *, ...) ATTRIBUTE_NORETURN;
++#if ENABLE_ASSERT_CHECKING
++#define gcc_assert_and_retry_with_lowered_optimisation_level(EXPR) 	\
++   ((void)(!(EXPR) ? tgv_abort ("in %s, at %s:%d", __FUNCTION__, trim_filename (__FILE__), __LINE__), 0 : 0))
++#else
++#define gcc_assert_and_retry_with_lowered_optimisation_level(EXPR)	\
++   gcc_assert (EXPR)
++#endif
++
+ #ifdef ENABLE_CHECKING
+ #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
+ #else
+--- a/src/gcc/gcc.c
++++ b/src/gcc/gcc.c
+@@ -252,6 +252,7 @@ static const char *convert_filename (con
+ #if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
+ static void retry_ice (const char *prog, const char **argv);
+ #endif
++static const char **tgv_argv(const char **);
+ 
+ static const char *getenv_spec_function (int, const char **);
+ static const char *if_exists_spec_function (int, const char **);
+@@ -2580,6 +2581,7 @@ execute (void)
+ {
+   int i;
+   int n_commands;		/* # of command.  */
++  int retry_tgv = 0;
+   char *string;
+   struct pex_obj *pex;
+   struct command
+@@ -2645,7 +2647,8 @@ execute (void)
+ 
+   /* If -v, print what we are about to do, and maybe query.  */
+ 
+-  if (verbose_flag)
++  do {
++  if (verbose_flag || retry_tgv)
+     {
+       /* For help listings, put a blank line between sub-processes.  */
+       if (print_help_list)
+@@ -2775,13 +2778,12 @@ execute (void)
+ 	      pfatal_with_name (errmsg);
+ 	    }
+ 	}
+-
+-      if (i && string != commands[i].prog)
+-	free (CONST_CAST (char *, string));
+     }
+ 
+   execution_count++;
+ 
++  retry_tgv &= ~0x80;
++
+   /* Wait for all the subprocesses to finish.  */
+ 
+   {
+@@ -2833,6 +2835,35 @@ execute (void)
+ 	    /* For ICEs in cc1, cc1obj, cc1plus see if it is
+ 	       reproducible or not.  */
+ 	    const char *p;
++	    if (WEXITSTATUS (status) == TGV_EXIT_CODE
++		&& i == 0
++		&& (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
++		&& ! strncmp (p + 1, "cc1", 3)) {
++	      if (retry_tgv == 0) {
++		commands[0].argv = tgv_argv(commands[0].argv);
++		retry_tgv = 0x81;
++		goto foo_tgv;
++              }
++              if (retry_tgv == 1) {
++		size_t qqq = 0;
++
++		while (commands[0].argv[qqq])
++		  ++qqq;
++		commands[0].argv[--qqq] = "-O1";
++		retry_tgv = 0x82;
++		goto foo_tgv;
++              }
++              if (retry_tgv == 2) {
++		size_t qqq = 0;
++
++		while (commands[0].argv[qqq])
++		  ++qqq;
++		commands[0].argv[--qqq] = "-O0";
++		retry_tgv = 0x83;
++		goto foo_tgv;
++              }
++	      retry_tgv = 4;
++	    }
+ 	    if (WEXITSTATUS (status) == ICE_EXIT_CODE
+ 		&& i == 0
+ 		&& (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
+@@ -2841,6 +2872,7 @@ execute (void)
+ #endif
+ 	    if (WEXITSTATUS (status) > greatest_status)
+ 	      greatest_status = WEXITSTATUS (status);
++ foo_tgv:
+ 	    ret_code = -1;
+ 	  }
+ 
+@@ -2895,12 +2927,12 @@ execute (void)
+ 	      }
+ 	  }
+       }
+-
+-    if (commands[0].argv[0] != commands[0].prog)
+-      free (CONST_CAST (char *, commands[0].argv[0]));
+-
++   if (!(retry_tgv & 0x80))
+     return ret_code;
++   retry_tgv &= ~0x80;
+   }
++  } while (retry_tgv < 4);
++  return TGV_EXIT_CODE;
+ }
+ 
+ /* Find all the switches given to us
+@@ -8838,3 +8870,23 @@ convert_white_space (char *orig)
+   else
+     return orig;
+ }
++
++static const char **
++tgv_argv(const char **oargv)
++{
++	size_t qqq = 0;
++	const char **rv;
++
++	while (oargv[qqq])
++		++qqq;
++	rv = (const char **)xmalloc((qqq + 3) * sizeof(const char *));
++	qqq = 0;
++	while (oargv[qqq]) {
++		rv[qqq] = oargv[qqq];
++		++qqq;
++	}
++	rv[qqq++] = "-fno-auto-inc-dec";
++	rv[qqq++] = "-Os";
++	rv[qqq] = NULL;
++	return (rv);
++}
+--- a/src/gcc/cselib.c
++++ b/src/gcc/cselib.c
+@@ -2370,7 +2370,7 @@ cselib_record_set (rtx dest, cselib_val
+       else
+ 	{
+ 	  /* The register should have been invalidated.  */
+-	  gcc_assert (REG_VALUES (dreg)->elt == 0);
++	  gcc_assert_and_retry_with_lowered_optimisation_level (REG_VALUES (dreg)->elt == 0);
+ 	  REG_VALUES (dreg)->elt = src_elt;
+ 	}
+ 
only in patch2:
unchanged:
--- gcc-4.8-4.8.1.orig/debian/patches/pr52714.diff
+++ gcc-4.8-4.8.1/debian/patches/pr52714.diff
@@ -0,0 +1,68 @@
+# DP: Proposed fix for PR rtl-optimization/52714:
+# DP: Revert gcc 4.8 to gcc the 4.5 version of the PR rtl-optimization/45695 fix:
+
+--- a/src/gcc/combine.c
++++ b/src/gcc/combine.c
+@@ -3690,41 +3690,42 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx
+ 	   && GET_CODE (XVECEXP (newpat, 0, 1)) == SET
+ 	   && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != ZERO_EXTRACT
+ 	   && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != STRICT_LOW_PART
++	   && ! use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 1)),
++				   DF_INSN_LUID (i2))
+ 	   && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 1)),
+ 				  XVECEXP (newpat, 0, 0))
+ 	   && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 0)),
+ 				  XVECEXP (newpat, 0, 1))
+ 	   && ! (contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 0)))
+-		 && contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 1)))))
++		 && contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 1))))
++#ifdef HAVE_cc0
++	   /* We cannot split the parallel into two sets if both sets
++	      reference cc0.  */
++	   && ! (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0))
++		 && reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 1)))
++#endif
++	   )
+     {
+       /* Normally, it doesn't matter which of the two is done first,
+-	 but the one that references cc0 can't be the second, and
+-	 one which uses any regs/memory set in between i2 and i3 can't
++	 but it does if one references cc0.  In that case, it has to
+ 	 be first.  */
+-      if (!use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 1)),
+-			      DF_INSN_LUID (i2))
+-#ifdef HAVE_cc0
+-	  && !reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0))
+-#endif
+-	 )
+-	{
+-	  newi2pat = XVECEXP (newpat, 0, 1);
+-	  newpat = XVECEXP (newpat, 0, 0);
+-	}
+-      else if (!use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 0)),
+-				   DF_INSN_LUID (i2))
+ #ifdef HAVE_cc0
+-	       && !reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 1))
+-#endif
+-	      )
++      if (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0)))
+ 	{
++	  if (use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 0)),
++				 DF_INSN_LUID (i2)))
++	    {
++	      undo_all ();
++	      return 0;
++	    }
+ 	  newi2pat = XVECEXP (newpat, 0, 0);
+ 	  newpat = XVECEXP (newpat, 0, 1);
+ 	}
+       else
++#endif
+ 	{
+-	  undo_all ();
+-	  return 0;
++	  newi2pat = XVECEXP (newpat, 0, 1);
++	  newpat = XVECEXP (newpat, 0, 0);
+ 	}
+ 
+       i2_code_number = recog_for_combine (&newi2pat, i2, &new_i2_notes);

Reply to: