Qing Zhao <qing.z...@oracle.com> writes: >> On Sep 25, 2020, at 7:53 AM, Richard Sandiford <richard.sandif...@arm.com> >> wrote: >> >> Qing Zhao <qing.z...@oracle.com> writes: >>> Hi, Richard, >>> >>> As you suggested, I added a default implementation of the target hook >>> “zero_cal_used_regs (HARD_REG_SET)” as following in my latest patch >>> >>> >>> /* The default hook for TARGET_ZERO_CALL_USED_REGS. */ >>> >>> void >>> default_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs) >> >> FWIW, I was suggesting to return the set of registers that are actually >> cleared too. Here you have the hook emit the asm statement, but IMO the >> way we generate the asm for a given set of registers should be entirely >> target-independent, and happen outside the hook. >> >> So the hook returning the set of cleared registers does two things: >> >> (1) It indicates which registers should be clobbered by the asm >> (which would be generated after calling the hook, but emitted >> before the sequence of instructions generated by the hook). > > For this purpose, this hook should return a Set of RTX that hold the cleared > registers, a HARD_REG_SET is not enough. > > Since in the ASM_OPERANDS, we will need the RTX for the register (not the > REGNO). > > Which data structure in GCC should be used here to hold this returned value > as Set of RTX ?
A HARD_REG_SET is enough. All the caller needs to know is: which registers were clobbered? It can then represent a clobber of R with a clobber of reg_regno_rtx[R]. The mode isn't important for single-register clobbers: clobbering a single register in one mode is equivalent to clobbering it in another mode. None of the register contents survive the clobber. >> (2) It indicates which registers should be treated as live on return. >> >> FWIW, for (2), I'd recommend storing the returned HARD_REG_SET in crtl. > > Instead of storing this info in crtl, in my current patch, I added the > following in “df-scan.c": > +static HARD_REG_SET zeroed_reg_set; > > And routines that manipulate this HARD_REG_SET. > I think that this should serve the same purpose as storing it to crtl? Storing it in crtl is better for two reasons: - Using global statics for this kind of thing makes it harder to compile functions in parallel. (Work is underway to allow that.) - Having the information in crtl reduces the risk that information from one function will get reused for another function, without the variable being reinitialised inbetween. Thanks, Richard