On Tue, Jan 21, 2025 at 5:45 PM Andrew Pinski <pins...@gmail.com> wrote:
>
> On Thu, Aug 8, 2024 at 2:07 PM Andrew Pinski <pins...@gmail.com> wrote:
> >
> > 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.
>
> I decided to re-apply the patch to the trunk locally and see if I
> could debug what was going wrong. The good news is the bootstrap
> failure is gone.
> The bad news is I don't know why though. I am going to see if I can
> bisect where the failure mode I was getting disappears. That should
> help decide if the bug has got latent or really fixed.

Just a small update before I go to bed.

Here are some information on the revisions which work/don't work (with
the patch re-applied):
r15-5746-g0547dbb725b6d8 fails the way it was reported above
r15-6350-gbb829ce157f8b4 fails with a  bootstrap comparison
r15-6351-g24df430108c0cd fails with a bootstrap comparison

r15-7077-g96f4ba4d19a765 works
r15-7116-g3f641a8f1d1fafc0c6531aee185d0e74998987d5 works

I will be testing more revisions tomorrow. But it looks like we are
down to ~700 revisions.

Thanks,
Andrew Pinski


>
> Thanks,
> Andrew Pinski
>
> >
> > Thanks,
> > Andrew
> >
> > >
> > > Thanks,
> > > jeff

Reply via email to