On Wed, Jul 7, 2021 at 10:54 PM Segher Boessenkool
<seg...@kernel.crashing.org> wrote:
>
> Hi!
>
> On Wed, Jul 07, 2021 at 10:15:08AM +0200, Richard Biener wrote:
> > On Wed, Jul 7, 2021 at 4:40 AM Hongtao Liu via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > > On Tue, Jul 6, 2021 at 9:37 AM Hongtao Liu <crazy...@gmail.com> wrote:
> > > > On Tue, Jul 6, 2021 at 7:31 AM Segher Boessenkool
> > > > <seg...@kernel.crashing.org> wrote:
> > > > > I ran into this in shrink-wrap.c today.
> > > > >
> > > > > On Thu, Jun 03, 2021 at 02:54:07PM +0800, liuhongt via Gcc-patches 
> > > > > wrote:
> > > > > > Use "used" flag for CALL_INSN to indicate it's a fake call. If it's 
> > > > > > a
> > > > > > fake call, it won't have its own function stack.
> > > > >
> > > > > Could you document somewhere what a "fake call" *is*?  Including what
> > > > > that means to RTL, how this is expected to be used, etc.?  In rtl.h is
> > > > fake call is used for TARGET_INSN_CALLEE_ABI, i'll add comments for
> > > > #define FAKE_CALL_P(RTX) in rtl.h
> > >
> > >
> > > Here's the patch I'm going to check in.
>
> Which doesn't do any of the things I asked for :-(  It doesn't say what
> a "fake call" is, it doesn't say what its semantics are, it doesn't say
> how it is exected to be used.
>
> So, a "FAKE_CALL" is very much a *real* call, on the RTL level, which is
> where we are here.  But you want it to be treated differently because it
> will eventually be replaced by different insns.
It's CALL_INSN on the rtl level,  but it's just a normal instruction
that it doesn't have a call stack, and it doesn't affect the control
flow
>
> This causes all kinds of unrelated code to need confusing changes, made
> much worse because the name "FAKE_CALL" is the opposite of what it does.
>
> As long as your description of it only says how it is (ab)used in one
> case, I will call it a hack, and a gross hack at that.
>
>
> > > --- a/gcc/rtl.h
> > > +++ b/gcc/rtl.h
> > > @@ -840,7 +840,13 @@ struct GTY(()) rtvec_def {
> > >  #define CALL_P(X) (GET_CODE (X) == CALL_INSN)
> > >
> > >  /* 1 if RTX is a call_insn for a fake call.
> > > -   CALL_INSN use "used" flag to indicate it's a fake call.  */
> > > +   CALL_INSN use "used" flag to indicate it's a fake call.
> > > +   Used by the x86 vzeroupper instruction,
> > > +   in order to solve the problem of partial clobber registers,
> > > +   vzeroupper is defined as a call_insn with a special callee_abi,
> > > +   but it is not a real call and therefore has no function stack
> > > +   of its own.
>
> So because of this one thing (you need to insert partial clobbers) you
> force all kinds of unrelated code to have changes, namely, code thatt
> needs to do something with calls, but now you do not want to have that
> doone on some calls because you promise that call will disappear
> eventually, and it cannot cause any problems in the mean time?
>
> I am not convinced.  This is not design, this is a terrible hack, this
> is the opposite direction we should go in.

Quote from  https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570634.html

> Also i grep CALL_P or CALL_INSN in GCC source codes, there are many
> places which hold the assumption CALL_P/CALL_INSN is a real call.
> Considering that vzeroupper is used a lot on the i386 backend, I'm a
> bit worried that this implementation solution will be a bottomless
> pit.

Maybe, but I think the same is true for CLOBBER_HIGH.  If we have
a third alternative then we should consider it, but I think the
call approach is still going to be less problematic then CLOBBER_HIGH.

The main advantage of the call approach is that the CALL_P handling
is (mostly) conservatively correct and performance problems are just
a one-line change.  The CLOBBER_HIGH approach instead requires
changes to the way that passes track liveness information for
non-call instructions (so is much more than a one-line change).
Also, treating a CLOBBER_HIGH like a CLOBBER isn't conservatively
correct, because other code might be relying on part of the register
being preserved.

>
> > that doesn't set up a stack frame is fake as well?  Maybe
> >
> >  "CALL_INSN use "used" flag to indicate the instruction
> >   does not transfer control."
> >
> > thus that this call is not affecting regular control flow? (it might
> > eventually still trap and thus cause non-call EH?)
>
> How it is used in shrink-wrap requires it to not have a stack frame (in
> the compiler sense).
>
> > Not sure if "no function stack of its own" is a good constraint,
> > vzeroupper does not perform any call or jump.
>
> Yeah.  This stuff needs a rethink.
>
> What is wrong with just using an unspec and clobbers?
>
>
> Segher



-- 
BR,
Hongtao

Reply via email to