Commit f7e088e7 by Eric Botcazou

function.c (assign_parm_setup_reg): For a parameter passed by pointer and which…

function.c (assign_parm_setup_reg): For a parameter passed by pointer and which can live in a register...

	* function.c (assign_parm_setup_reg): For a parameter passed by pointer
	and which can live in a register, always retrieve the value on entry.
	* var-tracking.c (add_stores): Treat the copy on entry for a parameter
	passed by invisible reference specially.
	(emit_notes_in_bb) <MO_VAL_USE>: Emit notes before the instruction.
	(vt_add_function_parameter): Correctly deal with a parameter passed by
	invisible reference.

From-SVN: r202102
parent bec9ec3f
2013-08-29 Jan Hubicka <jh@suse.cz> 2013-08-30 Eric Botcazou <ebotcazou@adacore.com>
* function.c (assign_parm_setup_reg): For a parameter passed by pointer
and which can live in a register, always retrieve the value on entry.
* var-tracking.c (add_stores): Treat the copy on entry for a parameter
passed by invisible reference specially.
(emit_notes_in_bb) <MO_VAL_USE>: Emit notes before the instruction.
(vt_add_function_parameter): Correctly deal with a parameter passed by
invisible reference.
2013-08-30 Jan Hubicka <jh@suse.cz>
* tree.c (set_call_expr_flags): Fix handling of TM_PURE. * tree.c (set_call_expr_flags): Fix handling of TM_PURE.
......
...@@ -3101,17 +3101,27 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, ...@@ -3101,17 +3101,27 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm,
emit_move_insn (parmreg, validated_mem); emit_move_insn (parmreg, validated_mem);
/* If we were passed a pointer but the actual value can safely live /* If we were passed a pointer but the actual value can safely live
in a register, put it in one. */ in a register, retrieve it and use it directly. */
if (data->passed_pointer if (data->passed_pointer && TYPE_MODE (TREE_TYPE (parm)) != BLKmode)
&& TYPE_MODE (TREE_TYPE (parm)) != BLKmode
/* If by-reference argument was promoted, demote it. */
&& (TYPE_MODE (TREE_TYPE (parm)) != GET_MODE (DECL_RTL (parm))
|| use_register_for_decl (parm)))
{ {
/* We can't use nominal_mode, because it will have been set to /* We can't use nominal_mode, because it will have been set to
Pmode above. We must use the actual mode of the parm. */ Pmode above. We must use the actual mode of the parm. */
parmreg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm))); if (use_register_for_decl (parm))
mark_user_reg (parmreg); {
parmreg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm)));
mark_user_reg (parmreg);
}
else
{
int align = STACK_SLOT_ALIGNMENT (TREE_TYPE (parm),
TYPE_MODE (TREE_TYPE (parm)),
TYPE_ALIGN (TREE_TYPE (parm)));
parmreg
= assign_stack_local (TYPE_MODE (TREE_TYPE (parm)),
GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parm))),
align);
set_mem_attributes (parmreg, parm, 1);
}
if (GET_MODE (parmreg) != GET_MODE (DECL_RTL (parm))) if (GET_MODE (parmreg) != GET_MODE (DECL_RTL (parm)))
{ {
......
2013-08-30 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/guality/param-1.c: New test.
* gcc.dg/guality/param-2.c: Likewise.
2013-08-30 Richard Biener <rguenther@suse.de> 2013-08-30 Richard Biener <rguenther@suse.de>
PR tree-optimization/58228 PR tree-optimization/58228
......
/* { dg-do run } */
/* { dg-options "-g" } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
typedef __UINTPTR_TYPE__ uintptr_t;
__attribute__((noinline, noclone)) int
sub (int a, int b)
{
return a - b;
}
typedef struct { uintptr_t pa; uintptr_t pb; } fatp_t
__attribute__ ((aligned (2 * __alignof__ (uintptr_t))));
__attribute__((noinline, noclone)) void
foo (fatp_t str, int a, int b)
{
int i = sub (a, b);
if (i == 0) /* BREAK */
i = sub (b, a);
}
int
main (void)
{
fatp_t ptr = { 31415927, 27182818 };
foo (ptr, 1, 2);
return 0;
}
/* { dg-final { gdb-test 20 "str.pa" "31415927" } } */
/* { dg-final { gdb-test 20 "str.pb" "27182818" } } */
/* { dg-do run } */
/* { dg-options "-g -fno-var-tracking-assignments" } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O1" } } */
typedef __UINTPTR_TYPE__ uintptr_t;
__attribute__((noinline, noclone)) int
sub (int a, int b)
{
return a - b;
}
typedef struct { uintptr_t pa; uintptr_t pb; } fatp_t
__attribute__ ((aligned (2 * __alignof__ (uintptr_t))));
__attribute__((noinline, noclone)) void
foo (fatp_t str, int a, int b)
{
int i = sub (a, b);
if (i == 0) /* BREAK */
foo (str, a - 1, b);
}
int
main (void)
{
fatp_t ptr = { 31415927, 27182818 };
foo (ptr, 1, 2);
return 0;
}
/* { dg-final { gdb-test 20 "str.pa" "31415927" } } */
/* { dg-final { gdb-test 20 "str.pb" "27182818" } } */
...@@ -5836,7 +5836,24 @@ add_stores (rtx loc, const_rtx expr, void *cuip) ...@@ -5836,7 +5836,24 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
{ {
rtx xexpr = gen_rtx_SET (VOIDmode, loc, src); rtx xexpr = gen_rtx_SET (VOIDmode, loc, src);
if (same_variable_part_p (src, REG_EXPR (loc), REG_OFFSET (loc))) if (same_variable_part_p (src, REG_EXPR (loc), REG_OFFSET (loc)))
mo.type = MO_COPY; {
/* If this is an instruction copying (part of) a parameter
passed by invisible reference to its register location,
pretend it's a SET so that the initial memory location
is discarded, as the parameter register can be reused
for other purposes and we do not track locations based
on generic registers. */
if (MEM_P (src)
&& REG_EXPR (loc)
&& TREE_CODE (REG_EXPR (loc)) == PARM_DECL
&& DECL_MODE (REG_EXPR (loc)) != BLKmode
&& MEM_P (DECL_INCOMING_RTL (REG_EXPR (loc)))
&& XEXP (DECL_INCOMING_RTL (REG_EXPR (loc)), 0)
!= arg_pointer_rtx)
mo.type = MO_SET;
else
mo.type = MO_COPY;
}
else else
mo.type = MO_SET; mo.type = MO_SET;
mo.u.loc = xexpr; mo.u.loc = xexpr;
...@@ -9086,7 +9103,7 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set) ...@@ -9086,7 +9103,7 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set)
else else
var_mem_set (set, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL); var_mem_set (set, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN, set->vars); emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN, set->vars);
} }
break; break;
...@@ -9533,12 +9550,11 @@ vt_add_function_parameter (tree parm) ...@@ -9533,12 +9550,11 @@ vt_add_function_parameter (tree parm)
if (!vt_get_decl_and_offset (incoming, &decl, &offset)) if (!vt_get_decl_and_offset (incoming, &decl, &offset))
{ {
if (REG_P (incoming) || MEM_P (incoming)) if (MEM_P (incoming))
{ {
/* This means argument is passed by invisible reference. */ /* This means argument is passed by invisible reference. */
offset = 0; offset = 0;
decl = parm; decl = parm;
incoming = gen_rtx_MEM (GET_MODE (decl_rtl), incoming);
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment