On Tue, Nov 05, 2024 at 07:24:42PM +0100, Uros Bizjak wrote:
> On Tue, Nov 5, 2024 at 7:12 PM Jakub Jelinek <ja...@redhat.com> wrote:
> >
> > On Tue, Nov 05, 2024 at 06:55:33PM +0100, Uros Bizjak wrote:
> > > The difference between redzoned and non-redzoned code is *two*
> > > instructions that decrease and increase stack pointer, which I think
> > > is an acceptable compromise between correctness and performance. Also
> >
> > It is not.  Because this price is paid for the 99.9% of inline asms that
> > don't really need it.  It is much better to pay it portably by adding
> > the two instructions to the inline asm that really need it.  That is
> > something that will not work just with new GCC versions, but all past
> > releases as well.
> > And by adding a new clobber allow better fine tuning (e.g. if one knows they
> > use inline asm that needs to do calls many times in the same otherwise leaf
> > function, they can use the clobber to force it).
> 
> Maybe inventing "asm call", implicitly volatile asm variant could
> solve this issue? This kind of asm would signal the compiler that the
> function manipulates stack and should not be marked as leaf.

It doesn't have to be call.
asm ("pushf; popq %0" : "=r" (x));
needs it too, unless one subtracts 128 from rsp first and adds it back
afterwards.  And I really think clobbers are the best way to express it,
the problem is that the push or call in there clobbers the red-zone.
Most targets don't have something like red-zone, I'm aware of just
x86-64 and some ABIs on rs6000, anything else?  Inventing new keywords
in the FE just because of this looks like an overkill to me, while we already
have an easy way to add further clobbers, just parse them in
decode_reg_name_and_count, return -5, build something for it
in expand_asm_stmt (perhaps with a target hook which also determines if
the clobber is meaningful on the arch) and then just in the backends deal
with it as needed.

        Jakub

Reply via email to