This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Fix PR3256
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH: Fix PR3256
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 19 Jul 2001 19:18:10 -0700
This patch fixes the previously discussed PR3256. Bootstrapped
and tested on sparc-sun-solaris2.8, installed on the mainline and
on the branch.
The test-case in the PR is marked as proprietary, so I am not
installing a test-case for this fix.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2001-07-19 Mark Mitchell <mark@codesourcery.com>
* reorg.c (fill_simple_delay_slots): If an instruction might throw
an exception that will be caught within this function, do not fill
its delay slot with any subsequent instruction.
Index: reorg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reorg.c,v
retrieving revision 1.56.4.2
diff -c -p -r1.56.4.2 reorg.c
*** reorg.c 2001/05/12 20:32:39 1.56.4.2
--- reorg.c 2001/07/19 23:42:04
*************** fill_simple_delay_slots (non_jumps_p)
*** 2223,2228 ****
--- 2223,2249 ----
fill_eager_delay_slots anyways, it was just deleted. */
if (slots_filled != slots_to_fill
+ /* If this instruction could throw an exception which is
+ caught in the same function, then it's not safe to fill
+ the delay slot with an instruction from beyond this
+ point. For example, consider:
+
+ int i = 2;
+
+ try {
+ f();
+ i = 3;
+ } catch (...) {}
+
+ return i;
+
+ Even though `i' is a local variable, we must be sure not
+ to put `i = 3' in the delay slot if `f' might throw an
+ exception.
+
+ Presumably, we should also check to see if we could get
+ back to this function via `setjmp'. */
+ && !can_throw_internal (insn)
&& (GET_CODE (insn) != JUMP_INSN
|| ((condjump_p (insn) || condjump_in_parallel_p (insn))
&& ! simplejump_p (insn)