There's code in function.c to set the return register to the address of a returned structure even though the return really happens through the struct pointer passed as an invisible argument. This is unwanted on ptx, where having a return value does not match the declaration of the function or the calls to it, causing inconsistencies that the assembler complains about.
gcc/ * target.def (omit_struct_return_reg): New data hook. * doc/tm.texi.in: Add @hook TARGET_OMIT_STRUCT_RETURN_REG. * doc/tm.texi: Regenerate. * function.c (expand_function_end): Use it. ------------------------------------------------------------------------ Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 422355) +++ gcc/doc/tm.texi (revision 422356) @@ -4560,6 +4560,14 @@ need more space than is implied by @code saving and restoring an arbitrary return value. @end defmac +@deftypevr {Target Hook} bool TARGET_OMIT_STRUCT_RETURN_REG +Normally, when a function returns a structure by memory, the address +is passed as an invisible pointer argument, but the compiler also +arranges to return the address from the function like it would a normal +pointer return value. Define this to true if that behaviour is +undesirable on your target. +@end deftypevr + @deftypefn {Target Hook} bool TARGET_RETURN_IN_MSB (const_tree @var{type}) This hook should return true if values of type @var{type} are returned at the most significant end of a register (in other words, if they are Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 422355) +++ gcc/doc/tm.texi.in (revision 422356) @@ -3769,6 +3769,8 @@ need more space than is implied by @code saving and restoring an arbitrary return value. @end defmac +@hook TARGET_OMIT_STRUCT_RETURN_REG + @hook TARGET_RETURN_IN_MSB @node Aggregate Return Index: gcc/target.def =================================================================== --- gcc/target.def (revision 422355) +++ gcc/target.def (revision 422356) @@ -3601,6 +3601,16 @@ structure value address at the beginning to emit adjusting code, you should do it at this point.", rtx, (tree fndecl, int incoming), hook_rtx_tree_int_null) + +DEFHOOKPOD +(omit_struct_return_reg, + "Normally, when a function returns a structure by memory, the address\n\ +is passed as an invisible pointer argument, but the compiler also\n\ +arranges to return the address from the function like it would a normal\n\ +pointer return value. Define this to true if that behaviour is\n\ +undesirable on your target.", + bool, false) + DEFHOOK (return_in_memory, "This target hook should return a nonzero value to say to return the\n\ Index: gcc/function.c =================================================================== --- gcc/function.c (revision 422355) +++ gcc/function.c (revision 422356) @@ -5179,8 +5179,8 @@ expand_function_end (void) If returning a structure PCC style, the caller also depends on this value. And cfun->returns_pcc_struct is not necessarily set. */ - if (cfun->returns_struct - || cfun->returns_pcc_struct) + if ((cfun->returns_struct || cfun->returns_pcc_struct) + && !targetm.calls.omit_struct_return_reg) { rtx value_address = DECL_RTL (DECL_RESULT (current_function_decl)); tree type = TREE_TYPE (DECL_RESULT (current_function_decl));