diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e626352ec1..17bb0cd6962 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-07-11 Jakub Jelinek + + PR target/40668 + * function.c (assign_parm_setup_stack): Adjust + MEM_OFFSET (data->stack_parm) if promoted_mode is different + from nominal_mode on big endian. + 2009-07-11 Paolo Bonzini * expmed.c (emit_store_flag_1): Fix choice of zero vs. sign extension. diff --git a/gcc/function.c b/gcc/function.c index 93244dba76b..258f5941950 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -2976,9 +2976,17 @@ assign_parm_setup_stack (struct assign_parm_data_all *all, tree parm, TYPE_UNSIGNED (TREE_TYPE (parm))); if (data->stack_parm) - /* ??? This may need a big-endian conversion on sparc64. */ - data->stack_parm - = adjust_address (data->stack_parm, data->nominal_mode, 0); + { + int offset = subreg_lowpart_offset (data->nominal_mode, + GET_MODE (data->stack_parm)); + /* ??? This may need a big-endian conversion on sparc64. */ + data->stack_parm + = adjust_address (data->stack_parm, data->nominal_mode, 0); + if (offset && MEM_OFFSET (data->stack_parm)) + set_mem_offset (data->stack_parm, + plus_constant (MEM_OFFSET (data->stack_parm), + offset)); + } } if (data->entry_parm != data->stack_parm) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a477b3b9b6..87d57084e95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-07-11 Jakub Jelinek + + PR target/40668 + * gcc.c-torture/execute/pr40668.c: New test. + 2009-07-11 Paolo Bonzini * gcc.c-torture/execute/20090711-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr40668.c b/gcc/testsuite/gcc.c-torture/execute/pr40668.c new file mode 100644 index 00000000000..70fe63f8916 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr40668.c @@ -0,0 +1,35 @@ +static void +foo (unsigned int x, void *p) +{ + __builtin_memcpy (p, &x, sizeof x); +} + +void +bar (int type, void *number) +{ + switch (type) + { + case 1: + foo (0x12345678, number); + break; + case 7: + foo (0, number); + break; + case 8: + foo (0, number); + break; + case 9: + foo (0, number); + break; + } +} + +int +main (void) +{ + unsigned int x; + bar (1, &x); + if (x != 0x12345678) + __builtin_abort (); + return 0; +}