From 93d89886b5b6304307cadbc71dfed4ccea4568a5 Mon Sep 17 00:00:00 2001 From: hainque Date: Mon, 13 Sep 2010 14:18:31 +0000 Subject: [PATCH] * fwprop.c (forward_propagate_and_simplify): Only attach a REG_EQUAL note to an insn if the destination is a register. * gcse.c (try_replace_reg): Likewise. testsuite/ * gnat.dg/memtrap.adb: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164245 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/fwprop.c | 9 +++++---- gcc/gcse.c | 10 ++++------ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/memtrap.adb | 30 ++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/memtrap.adb diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc5d33d..9629287 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-09-13 Olivier Hainque + + * fwprop.c (forward_propagate_and_simplify): Only attach a + REG_EQUAL note to an insn if the destination is a register. + * gcse.c (try_replace_reg): Likewise. + 2010-09-13 Richard Guenther PR tree-optimization/45611 diff --git a/gcc/fwprop.c b/gcc/fwprop.c index 006dca3..b54ff50 100644 --- a/gcc/fwprop.c +++ b/gcc/fwprop.c @@ -1294,10 +1294,11 @@ forward_propagate_and_simplify (df_ref use, rtx def_insn, rtx def_set) loc = &SET_SRC (use_set); /* Do not replace an existing REG_EQUAL note if the insn is not - recognized. Either we're already replacing in the note, or - we'll separately try plugging the definition in the note and - simplifying. */ - set_reg_equal = (note == NULL_RTX); + recognized. Either we're already replacing in the note, or we'll + separately try plugging the definition in the note and simplifying. + And only install a REQ_EQUAL note when the destination is a REG, + as the note would be invalid otherwise. */ + set_reg_equal = (note == NULL_RTX && REG_P (SET_DEST (use_set))); } if (GET_MODE (*loc) == VOIDmode) diff --git a/gcc/gcse.c b/gcc/gcse.c index 775c7e1..39a5d22 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -2351,12 +2351,10 @@ try_replace_reg (rtx from, rtx to, rtx insn) && validate_change (insn, &SET_SRC (set), src, 0)) success = 1; - /* If we've failed to do replacement, have a single SET, don't already - have a note, and have no special SET, add a REG_EQUAL note to not - lose information. */ - if (!success && note == 0 && set != 0 - && GET_CODE (SET_DEST (set)) != ZERO_EXTRACT - && GET_CODE (SET_DEST (set)) != STRICT_LOW_PART) + /* If we've failed perform the replacement, have a single SET to + a REG destination and don't yet have a note, add a REG_EQUAL note + to not lose information. */ + if (!success && note == 0 && set != 0 && REG_P (SET_DEST (set))) note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 87b5f90..f01d8ba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-12 Olivier Hainque + + * gnat.dg/memtrap.adb: New test. + 2010-09-11 Francois-Xavier Coudert * gfortran.dg/promotion.f90: Fix options. diff --git a/gcc/testsuite/gnat.dg/memtrap.adb b/gcc/testsuite/gnat.dg/memtrap.adb new file mode 100644 index 0000000..b755759 --- /dev/null +++ b/gcc/testsuite/gnat.dg/memtrap.adb @@ -0,0 +1,30 @@ +-- { dg-do compile } +-- { dg-options "-O2" } + +with System; + +procedure Memtrap is + X : integer; + for X'address use System.Null_Address; +begin + X := 12; +exception + when others => null; +end; + +-- { dg-final { scan-assembler "__gnat_begin_handler" } } +-- { dg-do compile } +-- { dg-options "-O2" } + +with System; + +procedure Memtrap is + X : integer; + for X'address use System.Null_Address; +begin + X := 12; +exception + when others => null; +end; + +-- { dg-final { scan-assembler "__gnat_begin_handler|__gnat_raise_nodefer" } } -- 2.7.4