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]

[RFC] Fix PR 43562


I asked a related question several days ago about this PR but no replies:

http://gcc.gnu.org/ml/gcc/2010-03/msg00367.html

So I encouraged myself to have a try. I take a further look at this PR. It seems none of options 2, 3, 4, which were listed in the above email, is feasible, because the comment above backend_init_target says:

/* This function can be called multiple times to reinitialize the compiler
   back end when register classes or instruction sets have changed,
   before each function.  */

So we cannot add a flag to avoid multiple calls to init_caller_save. This leaves us only option 1. This patch just makes backend_init_target always call init_caller_save. Is it OK if no regressions found?


-- Jie Zhang CodeSourcery (650) 331-3385 x735
	* toplev.c (backend_init_target): Always calls init_caller_save.

	testsuite/
	* gcc.dg/pr43562.c: New test.

Index: toplev.c
===================================================================
--- toplev.c	(revision 157628)
+++ toplev.c	(working copy)
@@ -2183,8 +2183,7 @@ backend_init_target (void)
 
   /* We may need to recompute regno_save_code[] and regno_restore_code[]
      after a mode change as well.  */
-  if (flag_caller_saves)
-    init_caller_save ();
+  init_caller_save ();
   expand_dummy_function_end ();
 }
 
Index: testsuite/gcc.dg/pr43562.c
===================================================================
--- testsuite/gcc.dg/pr43562.c	(revision 0)
+++ testsuite/gcc.dg/pr43562.c	(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-options "-O0" } */
+/* { dg-do compile } */
+
+extern unsigned foo (void);
+extern void bar (void);
+
+__attribute__ ((optimize ("O2")))
+void bak ()
+{
+  unsigned a;
+  while (1)
+    {
+      a = foo ();
+      while (a)
+	{
+	  a &= 1;
+	  bar ();
+	}
+    }
+}

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