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]

PR14381 regression: move blockage


We've regressed on this PR.  To recap, the intention of generating
blockage at the end of a function is to prevent instructions that may
trap from being moved into the epilogue, where there isn't valid
unwinder data.

However, naked returns branch around the blockage instruction we emit,
preventing it from having any effect.  Note that jump_insn 19 branches
to code_label 21, bypassing the asm_input we just generated:


(note 15 14 22 NOTE_INSN_FUNCTION_END)

;; Start of basic block 2, registers live: (nil)
(note 22 15 19 2 [bb 2] NOTE_INSN_BASIC_BLOCK)

(jump_insn 19 22 20 2 (set (pc)
        (label_ref 21)) -1 (nil)
    (nil))
;; End of basic block 2, registers live:
 (nil)

(barrier 20 19 17)

;; Start of basic block 3, registers live: (nil)
(code_label 17 20 23 3 3 "" [0 uses])

(note 23 17 18 3 [bb 3] NOTE_INSN_BASIC_BLOCK)

(insn 18 23 21 3 (asm_input ("")) -1 (nil)
    (nil))
;; End of basic block 3, registers live:
 (nil)

;; Start of basic block 4, registers live: (nil)
(code_label 21 18 24 4 4 "" [1 uses])

(note 24 21 0 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
;; End of basic block 4, registers live:
 (nil)


This patch moves the logic that emits the blockage to immediately
after the label for the naked return from the function.

OK for trunk and all open branches?

Andrew.


2007-02-13  Andrew Haley  <aph@redhat.com>

	* function.c (expand_function_end): Move blockage to just after we
	emit the label for the naked return from the function.
 
Index: function.c
===================================================================
--- function.c	(revision 121711)
+++ function.c	(working copy)
@@ -4367,16 +4367,6 @@
       if (flag_exceptions)
 	sjlj_emit_function_exit_after (get_last_insn ());
     }
-  else
-    {
-      /* @@@ This is a kludge.  We want to ensure that instructions that
-	 may trap are not moved into the epilogue by scheduling, because
-	 we don't always emit unwind information for the epilogue.
-	 However, not all machine descriptions define a blockage insn, so
-	 emit an ASM_INPUT to act as one.  */
-      if (flag_non_call_exceptions)
-	emit_insn (gen_rtx_ASM_INPUT (VOIDmode, ""));
-    }
 
   /* If this is an implementation of throw, do what's necessary to
      communicate between __builtin_eh_return and the epilogue.  */
@@ -4518,6 +4508,14 @@
   /* Output the label for the naked return from the function.  */
   emit_label (naked_return_label);
 
+  /* @@@ This is a kludge.  We want to ensure that instructions that
+     may trap are not moved into the epilogue by scheduling, because
+     we don't always emit unwind information for the epilogue.
+     However, not all machine descriptions define a blockage insn, so
+     emit an ASM_INPUT to act as one.  */
+  if (! USING_SJLJ_EXCEPTIONS && flag_non_call_exceptions)
+    emit_insn (gen_rtx_ASM_INPUT (VOIDmode, ""));
+
   /* If stack protection is enabled for this function, check the guard.  */
   if (cfun->stack_protect_guard)
     stack_protect_epilogue ();


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