Hi! on 2024/3/24 02:37, Ajit Agarwal wrote: > > > On 23/03/24 9:33 pm, Peter Bergner wrote: >> On 3/23/24 4:33 AM, Ajit Agarwal wrote: >>>>> - else if (align_words < GP_ARG_NUM_REG) >>>>> + else if (align_words < GP_ARG_NUM_REG >>>>> + || (cum->hidden_string_length >>>>> + && cum->actual_parm_length <= GP_ARG_NUM_REG)) >>>> { >>>> if (TARGET_32BIT && TARGET_POWERPC64) >>>> return rs6000_mixed_function_arg (mode, type, align_words); >>>> >>>> return gen_rtx_REG (mode, GP_ARG_MIN_REG + align_words); >>>> } >>>> else >>>> return NULL_RTX; >>>> >>>> The old code for the unused hidden parameter (which was the 9th param) >>>> would >>>> fall thru to the "return NULL_RTX;" which would make the callee assume >>>> there >>>> was a parameter save area allocated. Now instead, we'll return a reg rtx, >>>> probably of r11 (r3 thru r10 are our param regs) and I'm guessing we'll now >>>> see a copy of r11 into a pseudo like we do for the other param regs. >>>> Is that a problem? Given it's an unused parameter, it'll probably get >>>> deleted >>>> as dead code, but could it cause any issues? What if we have more than one
I think Peter raised one good point, not sure it would really cause some issues, but the assigned reg goes beyond GP_ARG_MAX_REG, at least it is confusing to people especially without DCE like at -O0. Can we aggressively remove these candidates from DECL_ARGUMENTS chain? Does it cause any assertion to fail? BR, Kewen >>>> unused hidden parameter and we return r12 and r13 which have specific uses >>>> in our ABIs (eg, r13 is our TCB pointer), so it may not actually look dead. >>>> Have you verified what the callee RTL looks like after expand for these >>>> unused hidden parameters? Is there a rtx we can return that isn't a >>>> NULL_RTX >>>> which triggers the assumption of a parameter save area, but isn't a reg rtx >>>> which might lead to some rtl being generated? Would a (const_int 0) or >>>> something else work? >>>> >>>> >>> For the above use case it will return >>> >>> (reg:DI 5 %r5) and below check entry_parm = >>> (reg:DI 5 %r5) and the following check will not return TRUE and hence >>> parameter save area will not be allocated. >> >> Why r5?!?! The 8th (integer) param would return r10, so I'd assume if >> the next param was a hidden param, then it'd get the next gpr, so r11. >> How does it jump back to r5 which may have been used by the 3rd param? >> >> > My mistake its r11 only for hidden param. >> >> >> >>> It will not generate any rtx in the callee rtl code but it just used to >>> check whether to allocate parameter save area or not when number of args > >>> 8. >>> >>> /* If there is no incoming register, we need a stack. */ >>> entry_parm = rs6000_function_arg (args_so_far, arg); >>> if (entry_parm == NULL) >>> return true; >>> >>> /* Likewise if we need to pass both in registers and on the stack. */ >>> if (GET_CODE (entry_parm) == PARALLEL >>> && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX) >>> return true; >> >> Yes, this code in rs6000_parm_needs_stack() uses the rs6000_function_arg() >> return value as a boolean to tell us whether a parameter save area is >> required >> so what we return is unimportant other than to know it's not NULL_RTX. >> >> I'm more concerned about the use of the target hook >> targetm.calls.function_arg >> used in the generic parts of the compiler. What will that code do >> differently >> now that we return a reg rtx rather than NULL_RTX? Might that code use >> the reg rtx to emit something? I'd feel better if you could verify what >> happens in that code when we return a reg rtx for that 9th hidden param which >> isn't really being passed in a register. >> > > As per my understanding and debugging openBLAS code testcase I see that > reg_rtx returned inside the below IF condition is used for check whether > paramter save area is needed or not. > > In the generic code where targetm.calls.function_arg is called > in calls.cc returned rtx is used for PARALLEL case so that we can > check if we need to pass both in registers and stack then they emit > store with respect to return rtx. If we identify that we need only > registers for argument then it emits nothing. > > Thanks & Regards > Ajit >> >> Peter >> >>