PATCH: Use scheduling barrier in EH handler (c++/4012)

Jeff Sturm jsturm@one-point.com
Mon Sep 17 14:29:00 GMT 2001


On Mon, 3 Sep 2001, Richard Henderson wrote:
> On Sun, Sep 02, 2001 at 12:08:05PM -0400, Jeff Sturm wrote:
> > 	* except.c (dw2_build_landing_pads): Emit an ASM_INPUT as a
> > 	scheduling barrier after clobbers.  Suggested by Richard
> > 	Henderson.  Fixes c++/4012.
> 
> Don't emit the asm unless we emitted at least one clobber.

I had thought the ASM_INPUT would be benign in that case.  Here's a new
patch regardless.

Bootstrapped on 3.0 branch for sparc-sun-solaris2.7.

2001-09-17  Jeff Sturm  <jsturm@one-point.com>

	* except.c (dw2_build_landing_pads): New local
	clobbers_hard_regs.  Emit an ASM_INPUT as a scheduling
	barrier after clobbers.  Fixes c++/4012.

Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/except.c,v
retrieving revision 1.143.2.16
diff -u -p -r1.143.2.16 except.c
--- except.c	2001/08/08 21:19:56	1.143.2.16
+++ except.c	2001/09/17 20:18:10
@@ -1865,6 +1865,7 @@ dw2_build_landing_pads ()
     {
       struct eh_region *region = cfun->eh->region_array[i];
       rtx seq;
+      bool clobbers_hard_regs = false;
 
       /* Mind we don't process a region more than once.  */
       if (!region || region->region_number != i)
@@ -1901,7 +1902,19 @@ dw2_build_landing_pads ()
 	  if (r == INVALID_REGNUM)
 	    break;
 	  if (! call_used_regs[r])
-	    emit_insn (gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, r)));
+	    {
+	      emit_insn (gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, r)));
+	      clobbers_hard_regs = true;
+	    }
+	}
+
+      if (clobbers_hard_regs)
+	{
+	  /* @@@ This is a kludge.  Not all machine descriptions define a
+	     blockage insn, but we must not allow the code we just generated
+	     to be reordered by scheduling.  So emit an ASM_INPUT to act as
+	     blockage insn. */
+	  emit_insn (gen_rtx_ASM_INPUT (VOIDmode, ""));
 	}
 
       emit_move_insn (cfun->eh->exc_ptr,



More information about the Gcc-patches mailing list