diff options
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/expr.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/unchecked_convert9.adb | 15 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/unchecked_convert9.ads | 20 |
5 files changed, 52 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 85db69e..2c7af2a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-10-15 Eric Botcazou <ebotcazou@adacore.com> + + * expr.c (expand_expr_real_1) <VIEW_CONVERT_EXPR>: Do not unnecessarily + copy the object in the MEM_P case. + 2012-10-15 Richard Guenther <rguenther@suse.de> * tree-streamer-out.c (streamer_pack_tree_bitfields): Back @@ -37,7 +42,6 @@ (build_insn_chain): Use df_get_live_out instead of DF_LR_OUT. (do_reload): Remove the DF_LIVE problem for -O1. - 2012-10-14 Steven Bosscher <steven@gcc.gnu.org> PR rtl-optimization/54919 @@ -10270,10 +10270,15 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, { enum insn_code icode; - op0 = copy_rtx (op0); - if (TYPE_ALIGN_OK (type)) - set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type))); + { + /* ??? Copying the MEM without substantially changing it might + run afoul of the code handling volatile memory references in + store_expr, which assumes that TARGET is returned unmodified + if it has been used. */ + op0 = copy_rtx (op0); + set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type))); + } else if (mode != BLKmode && MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode) /* If the target does have special handling for unaligned diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f361e2aa..23f8c2e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-10-15 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/unchecked_convert9.ad[sb]: New test. + 2012-10-13 Jason Merrill <jason@redhat.com> * g++.dg/tls/thread_local7g.C: Require tls_native. diff --git a/gcc/testsuite/gnat.dg/unchecked_convert9.adb b/gcc/testsuite/gnat.dg/unchecked_convert9.adb new file mode 100644 index 0000000..133f3b9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/unchecked_convert9.adb @@ -0,0 +1,15 @@ +-- { dg-do compile } +-- { dg-options "-O -fdump-rtl-final" } + +package body Unchecked_Convert9 is + + procedure Proc is + L : Unsigned_32 := 16#55557777#; + begin + Var := Conv (L); + end; + +end Unchecked_Convert9; + +-- { dg-final { scan-rtl-dump-times "set \\(mem/v" 1 "final" } } +-- { dg-final { cleanup-rtl-dump "final" } } diff --git a/gcc/testsuite/gnat.dg/unchecked_convert9.ads b/gcc/testsuite/gnat.dg/unchecked_convert9.ads new file mode 100644 index 0000000..d4595f5 --- /dev/null +++ b/gcc/testsuite/gnat.dg/unchecked_convert9.ads @@ -0,0 +1,20 @@ +with System; +with Ada.Unchecked_Conversion; +with Interfaces; use Interfaces; + +package Unchecked_Convert9 is + + type R is record + H : Unsigned_16; + L : Unsigned_16; + end record; + + Var : R; + pragma Volatile (Var); + + function Conv is new + Ada.Unchecked_Conversion (Source => Unsigned_32, Target => R); + + procedure Proc; + +end Unchecked_Convert9; |