diff mbox

unbreak attribute((optimize(...))) on m68k (PR47908)

Message ID 20017.19599.454863.684658@pilspetsen.it.uu.se
State New
Headers show

Commit Message

Mikael Pettersson July 28, 2011, 11:48 a.m. UTC
On m68k-linux, gcc ICEs on any occurrence of attribute((optimize(...)))
ever since gcc-4.4.  Default optimization flags enable scheduling, which
the backend doesn't support for non-ColdFire targets.  The backend disables
scheduling for non-ColdFire targets when processing command-line options,
but fails to do so for the attribute optimize case, causing the ICE.

The fix for 4.6/4.7 is to hook TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE and
disable scheduling for non-ColdFire CPUs.

Tested on 4.6/4.7, no regressions but several test cases (see PR47908)
that previosuly failed now succeed.

Ok for trunk and 4.6?

(4.5 and 4.4 need a slightly different fix which I can provide if needed.)

/Mikael


gcc/

2011-07-28  Mikael Pettersson  <mikpe@it.uu.se>

	PR target/47908
	* config/m68k/m68k.c (m68k_override_options_after_change): New function.
	Disable instruction scheduling for non-ColdFire targets.
	(TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define.

Comments

Andreas Schwab July 30, 2011, 8:38 a.m. UTC | #1
Mikael Pettersson <mikpe@it.uu.se> writes:

> 2011-07-28  Mikael Pettersson  <mikpe@it.uu.se>
>
> 	PR target/47908
> 	* config/m68k/m68k.c (m68k_override_options_after_change): New function.
> 	Disable instruction scheduling for non-ColdFire targets.
> 	(TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define.

Ok for all active branches.

Andreas.
Mikael Pettersson July 30, 2011, 10:38 a.m. UTC | #2
Andreas Schwab writes:
 > Mikael Pettersson <mikpe@it.uu.se> writes:
 > 
 > > 2011-07-28  Mikael Pettersson  <mikpe@it.uu.se>
 > >
 > > 	PR target/47908
 > > 	* config/m68k/m68k.c (m68k_override_options_after_change): New function.
 > > 	Disable instruction scheduling for non-ColdFire targets.
 > > 	(TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define.
 > 
 > Ok for all active branches.
 > 
 > Andreas.

Thanks.

I will need help from someone with svn commit rights to apply this.
Specifically, the patch posted in
<http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02514.html>
should go into trunk and 4.6, while the patch attached to PR47908
<http://gcc.gnu.org/bugzilla/attachment.cgi?id=24863>
(same approach, different hook) should go into 4.5 and 4.4.

/Mikael
Andreas Schwab July 31, 2011, 3:11 p.m. UTC | #3
I have now checked it into trunk and 4.6 branch.

Andreas.
diff mbox

Patch

--- gcc-4.7-20110716/gcc/config/m68k/m68k.c.~1~	2011-06-16 15:45:47.000000000 +0200
+++ gcc-4.7-20110716/gcc/config/m68k/m68k.c	2011-07-28 11:26:57.000000000 +0200
@@ -136,6 +136,7 @@  static bool m68k_can_eliminate (const in
 static void m68k_conditional_register_usage (void);
 static bool m68k_legitimate_address_p (enum machine_mode, rtx, bool);
 static void m68k_option_override (void);
+static void m68k_override_options_after_change (void);
 static rtx find_addr_reg (rtx);
 static const char *singlemove_string (rtx *);
 static void m68k_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
@@ -235,6 +236,9 @@  static bool m68k_cannot_force_const_mem 
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE m68k_option_override
 
+#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
+#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE m68k_override_options_after_change
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS m68k_rtx_costs
 
@@ -634,6 +638,17 @@  m68k_option_override (void)
     }
 }
 
+static void
+m68k_override_options_after_change (void)
+{
+  if (m68k_sched_cpu == CPU_UNKNOWN)
+    {
+      flag_schedule_insns = 0;
+      flag_schedule_insns_after_reload = 0;
+      flag_modulo_sched = 0;
+    }
+}
+
 /* Generate a macro of the form __mPREFIX_cpu_NAME, where PREFIX is the
    given argument and NAME is the argument passed to -mcpu.  Return NULL
    if -mcpu was not passed.  */