diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2015-01-15 12:00:40 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2015-01-15 12:00:40 +0000 |
commit | 4caaffd2ff5ba985a4ffd48fa34bf05ae2b53274 (patch) | |
tree | bec929d175001c687b7c9cdcbd0856ffad796aac | |
parent | 71dc4c2957445376f222c97cc882e4a795c06ac9 (diff) |
* expr.c (expand_expr_real_1) <normal_inner_ref>: Use the expression to
set the memory attributes in all cases but clear MEM_EXPR if need be.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@219650 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/expr.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt47.adb | 31 |
4 files changed, 49 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c572f52c43d..9eea064fc00 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-01-15 Eric Botcazou <ebotcazou@adacore.com> + + * expr.c (expand_expr_real_1) <normal_inner_ref>: Use the expression to + set the memory attributes in all cases but clear MEM_EXPR if need be. + 2015-01-14 Jakub Jelinek <jakub@redhat.com> Backported from mainline diff --git a/gcc/expr.c b/gcc/expr.c index 6d68d37e95f..8d1844aa886 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -9992,7 +9992,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset, &mode1, &unsignedp, &volatilep, true); rtx orig_op0, memloc; - bool mem_attrs_from_type = false; + bool clear_mem_expr = false; /* If we got back the original object, something is wrong. Perhaps we are evaluating an expression too early. In any event, don't @@ -10088,7 +10088,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, memloc = assign_temp (TREE_TYPE (tem), 1, 1); emit_move_insn (memloc, op0); op0 = memloc; - mem_attrs_from_type = true; + clear_mem_expr = true; } if (offset) @@ -10273,17 +10273,17 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, if (op0 == orig_op0) op0 = copy_rtx (op0); - /* If op0 is a temporary because of forcing to memory, pass only the - type to set_mem_attributes so that the original expression is never - marked as ADDRESSABLE through MEM_EXPR of the temporary. */ - if (mem_attrs_from_type) - set_mem_attributes (op0, type, 0); - else - set_mem_attributes (op0, exp, 0); + set_mem_attributes (op0, exp, 0); if (REG_P (XEXP (op0, 0))) mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0)); + /* If op0 is a temporary because the original expressions was forced + to memory, clear MEM_EXPR so that the original expression cannot + be marked as addressable through MEM_EXPR of the temporary. */ + if (clear_mem_expr) + set_mem_expr (op0, NULL_TREE); + MEM_VOLATILE_P (op0) |= volatilep; if (mode == mode1 || mode1 == BLKmode || mode1 == tmode || modifier == EXPAND_CONST_ADDRESS diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc19b95c6bc..06eb6d99acb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-01-15 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt47.adb: New test. + 2015-01-14 Jakub Jelinek <jakub@redhat.com> Backported from mainline diff --git a/gcc/testsuite/gnat.dg/opt47.adb b/gcc/testsuite/gnat.dg/opt47.adb new file mode 100644 index 00000000000..cfe44eb1e65 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt47.adb @@ -0,0 +1,31 @@ +-- { dg-do run { target i?86-*-* x86_64-*-* alpha*-*-* ia64-*-* } } +-- { dg-options "-O2" } + +with Ada.Characters.Handling; use Ada.Characters.Handling; +with Interfaces; use Interfaces; +with Ada.Unchecked_Conversion; + +procedure Opt47 is + + subtype String4 is String (1 .. 4); + function To_String4 is new Ada.Unchecked_Conversion (Unsigned_32, String4); + type Arr is array (Integer range <>) of Unsigned_32; + Leaf : Arr (1 .. 4) := (1349478766, 1948272498, 1702436946, 1702061409); + Value : Unsigned_32; + Result : String (1 .. 32); + Last : Integer := 0; + +begin + for I in 1 .. 4 loop + Value := Leaf (I); + for J in reverse String4'Range loop + if Is_Graphic (To_String4 (Value)(J)) then + Last := Last + 1; + Result (Last) := To_String4 (Value)(J); + end if; + end loop; + end loop; + if Result (1) /= 'P' then + raise Program_Error; + end if; +end; |