This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix GCSE store motion bug with non-call exceptions
- From: Ulrich Weigand <weigand at i1 dot informatik dot uni-erlangen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 28 Apr 2004 04:48:38 +0200 (CEST)
- Subject: [PATCH] Fix GCSE store motion bug with non-call exceptions
Hello,
another bug exposed by switching Ada exceptions to DWARF-2 on s390:
GCSE store motion may replace an insn with REG_EH_REGION note by
one without, which seriously confuses the CFG machinery, leading
to an ICE.
This can happen if the store to be moved is in fact a memory-to-memory
move, and the *source* access may trap (and flag_non_call_exceptions
is true); see e.g. this example:
STORE_MOTION delete insn in BB 199:
(insn 2423 4048 4072 199 (set (mem/s/j:DI (plus:DI (reg/f:DI 34 %fp)
(const_int 1456 [0x5b0])) [21 A168b.electronics._tag+0 S8 A64])
(mem/i:DI (reg:DI 699) [10 c391002_3__electronics_moduleP+0 S8 A64])) 51 {*movdi_64} (nil)
(expr_list:REG_EQUAL (mem/i:DI (symbol_ref:DI ("c391002_3__electronics_moduleP") [flags 0x40] <var_decl 0x200003b2d00 c391002_3__electronics_moduleP>) [10 c391002_3__electronics_moduleP+0 S8 A64])
(expr_list:REG_EH_REGION (const_int 1 [0x1])
(nil))))
STORE MOTION replaced with insn:
(insn 4072 2423 3826 199 (set (reg:DI 706)
(mem/i:DI (reg:DI 699) [10 c391002_3__electronics_moduleP+0 S8 A64])) -1 (nil)
(nil))
I guess it might be possible to reconstruct a REG_EH_REGION note
in the replacement insn, but I'm not sure if this is completely
reliable (or even worth the effort). As the rest of GCSE doesn't
touch insns with REG_EH_REGION notes at all, I've added the same
check to the store motion code.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux,
fixes two ACATS test cases.
OK?
Bye,
Ulrich
ChangeLog:
* gcse.c (find_moveable_store): Do not accept store insns with
REG_EH_REGION note.
Index: gcc/gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.298
diff -c -p -r1.298 gcse.c
*** gcc/gcse.c 23 Mar 2004 09:33:30 -0000 1.298
--- gcc/gcse.c 28 Apr 2004 00:05:22 -0000
*************** find_moveable_store (rtx insn, int *regs
*** 7175,7180 ****
--- 7175,7185 ----
if (flag_non_call_exceptions && may_trap_p (dest))
return;
+ /* Even if the destination cannot trap, the source may. In this case we'd
+ need to handle updating the REG_EH_REGION note. */
+ if (find_reg_note (insn, REG_EH_REGION, NULL_RTX))
+ return;
+
ptr = ldst_entry (dest);
if (!ptr->pattern_regs)
ptr->pattern_regs = extract_mentioned_regs (dest);
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de