On Wed, Jul 18, 2012 at 7:46 PM, Steven Bosscher <stevenb....@gmail.com> wrote: > Hello, > > This is my proposed fix for PR53948. We don't want to put user > variables in callee-clobbered registers, but obviously function > arguments are OK there. REG_USERVAR_P is set on PARM_DECLs and on user > variables, so it can't be used to distinguish between the two. > > As it turns out, I can hi-jack a bit for that: 'unchanging' (currently > incorrectly documented as used on REG) for a new macro > REG_FUNCTION_PARM_P. I found one obvious place where this bit can be > used instead of REG_USERVAR_P, and probably there are a few more > places where this is useful (TBD, I'm going to look at all places > where RTL code looks at tree's PARM_DECL later). > > Bootstrapped&tested on powerpc64-unknown-linux-gnu. > OK for trunk?
Just being pointed back to this patch ... I wonder if simply looking at REG_EXPR of a REG_USERVAR_P reg and checking whether it's a PARM_DECL isn't good enough (and simpler)? I suppose the optabs.c change was the "real" fix, thus sth like Index: gcc/optabs.c =================================================================== --- gcc/optabs.c (revision 194552) +++ gcc/optabs.c (working copy) @@ -3848,9 +3848,13 @@ emit_libcall_block_1 (rtx insns, rtx tar rtx final_dest = target; rtx next, last, insn; - /* If this is a reg with REG_USERVAR_P set, then it could possibly turn - into a MEM later. Protect the libcall block from this change. */ - if (! REG_P (target) || REG_USERVAR_P (target)) + /* If this is a parameter with REG_USERVAR_P set, then it could possibly turn + into a MEM later (e.g. if a REG_EQUIV note is attached to the insns that + sets the reg). Protect the libcall block from this change. */ + if (! REG_P (target) + || (REG_USERVAR_P (target) + && REG_EXPR (target) != NULL_TREE + && TREE_CODE (REG_EXPR (target)) == PARM_DECL)) target = gen_reg_rtx (GET_MODE (target)); /* If we're using non-call exceptions, a libcall corresponding to an (untested) Thanks, Richard. > Ciao! > Steven > > PR debug/53948 > * rtl.h (REG_FUNCTION_PARM_P): New flag on a REG. Re-use 'unchaning'. > * emit-rtl.c (mark_function_parm_reg): New function. > * function.c (assign_parm_setup_reg): Use mark_function_parm_reg > instead of mark_user_reg. > * combine.c (can_change_dest_mode): Preserve REG_FUNCTION_PARM_P. > * web.c (entry_register): Likewise. > * reload1.c (reload): Likewise. > * ira-emit.c (ira_create_new_reg): Likewise. > * reginfo.c (reg_scan_mark_refs): Likewise. > * optabs.c (emit_libcall_block_1): Use REG_FUNCTION_PARM_P instead > of REG_USERVAR_P. > * regstat.c (dump_reg_info): Print REG_FUNCTION_PARM_P. > * doc/rtl.texi (REG_FUNCTION_PARM_P): Document it. > ('unchanging' flag): Fix documentation.