From 4c876b4f9f832e19e45997c812a325787842d177 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Fri, 28 Jul 1995 08:47:44 -0400 Subject: [PATCH] (i960_function_epilogue): Don't clear g14 for functions with an argument block. (i960_output_reg_insn): Likewise. (i960_output_call_insn): Clear g14 for functions wtih an argument block. From-SVN: r10178 --- gcc/config/i960/i960.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/config/i960/i960.c b/gcc/config/i960/i960.c index 35ce318ddc6..202d734bbbe 100644 --- a/gcc/config/i960/i960.c +++ b/gcc/config/i960/i960.c @@ -1311,10 +1311,10 @@ i960_function_epilogue (file, size) if (epilogue_string[0] != '\0') fprintf (file, "%s", epilogue_string); - /* Must clear g14 on return. */ + /* Must clear g14 on return if this function set it. + Only varargs/stdarg functions modify g14. */ - if (current_function_args_size != 0 - || VARARGS_STDARG_FUNCTION (current_function_decl)) + if (VARARGS_STDARG_FUNCTION (current_function_decl)) fprintf (file, "\tmov 0,g14\n"); fprintf (file, "\tret\n"); @@ -1362,8 +1362,13 @@ i960_output_call_insn (target, argsize_rtx, arg_pointer, insn) output_asm_insn ("callx %0", operands); + /* If the caller sets g14 to the address of the argblock, then the caller + must clear it after the return. */ + if (current_function_args_size != 0 || varargs_stdarg_function) output_asm_insn ("mov r3,g14", operands); + else if (argsize > 48) + output_asm_insn ("mov 0,g14", operands); return ""; } @@ -1385,8 +1390,10 @@ i960_output_ret_insn (insn) return lbuf; } - if (current_function_args_size != 0 - || VARARGS_STDARG_FUNCTION (current_function_decl)) + /* Must clear g14 on return if this function set it. + Only varargs/stdarg functions modify g14. */ + + if (VARARGS_STDARG_FUNCTION (current_function_decl)) output_asm_insn ("mov 0,g14", 0); if (i960_leaf_ret_reg >= 0) -- 2.30.2