On Wed, Jun 22, 2011 at 7:13 AM, Eric Botcazou <ebotca...@adacore.com> wrote: >> I fear this isn't enough considering pass-by-value aggregates that >> are callee copied. > > It's indeed not sufficient for arguments passed by reference but > callee-copied. > > This is PR target/49454. For gcc.c-torture/execute/20000717-1.c: > > typedef struct trio { int a, b, c; } trio; > > int > foo (trio t, int i) > { > return bar (i, t); > } > > yiedls in the .optimized dump: > > foo (struct trio t, int i) > { > int D.1968; > struct trio t.0; > > <bb 2>: > t.0 = t; > D.1968_2 = bar (i_1(D), t.0); > return D.1968_2; > } > > and the aggregate copy is elided by DSE because t.0 isn't may_be_aliased. > This > seems to be a pre-existing bug though: its address is passed to bar in RTL. > > -- > Eric Botcazou >
Is the following patch a reasonable fix for this case? I assume I should add similar code inside emit_library_call_value_1. -Easwaran --- gcc/calls.c (revision 175081) +++ gcc/calls.c (working copy) @@ -1073,6 +1073,8 @@ initialize_argument_information (int num_actuals A callee_copies = reference_callee_copied (args_so_far, TYPE_MODE (type), type, argpos < n_named_args); + if (callee_copies) + mark_addressable (args[i].tree_value); /* If we're compiling a thunk, pass through invisible references instead of making a copy. */