On Fri, Aug 2, 2024 at 7:30 AM Jeff Law <jeffreya...@gmail.com> wrote: > > > > On 8/1/24 4:12 AM, Surya Kumari Jangala wrote: > > lra: emit caller-save register spills before call insn [PR116028] > > > > LRA emits insns to save caller-save registers in the > > inheritance/splitting pass. In this pass, LRA builds EBBs (Extended > > Basic Block) and traverses the insns in the EBBs in reverse order from > > the last insn to the first insn. When LRA sees a write to a pseudo (that > > has been assigned a caller-save register), and there is a read following > > the write, with an intervening call insn between the write and read, > > then LRA generates a spill immediately after the write and a restore > > immediately before the read. The spill is needed because the call insn > > will clobber the caller-save register. > > > > If there is a write insn and a call insn in two separate BBs but > > belonging to the same EBB, the spill insn gets generated in the BB > > containing the write insn. If the write insn is in the entry BB, then > > the spill insn that is generated in the entry BB prevents shrink wrap > > from happening. This is because the spill insn references the stack > > pointer and hence the prolog gets generated in the entry BB itself. > > > > This patch ensures that the spill insn is generated before the call insn > > instead of after the write. This is also more efficient as the spill now > > occurs only in the path containing the call. > > > > 2024-08-01 Surya Kumari Jangala <jskum...@linux.ibm.com> > > > > gcc/ > > PR rtl-optimization/PR116028 > > * lra-constraints.cc (split_reg): Spill register before call > > insn. > > (latest_call_insn): New variable. > > (inherit_in_ebb): Track the latest call insn. > > > > gcc/testsuite/ > > PR rtl-optimization/PR116028 > > * gcc.dg/ira-shrinkwrap-prep-1.c: Remove xfail for powerpc. > > * gcc.dg/pr10474.c: Remove xfail for powerpc. > Implementation looks fine. I would suggest a comment indicating why > we're inserting before last_call_insn. Otherwise someone in the future > would have to find the patch submission to know why we're handling that > case specially. > > OK with that additional comment.
This causes bootstrap failure on aarch64-linux-gnu; self-tests fail at stage 2. Looks to be wrong code is produced compiling stage 2 compiler. I have not looked further than that right now. Thanks, Andrew > > Thanks, > jeff