On Wed, Nov 6, 2024 at 4:53 PM Jakub Jelinek <ja...@redhat.com> wrote:
>
> On Wed, Nov 06, 2024 at 04:27:51PM +0100, Uros Bizjak wrote:
> > I see. While my solution would fit nicely with the above
> > ASM_CALL_CONSTRAINT approach, the approach using ASM_CALL_CONSTRAINT
> > is wrong by itself.
> >
> > Oh, well.
> >
> > Anyway, I guess "redzone" clobber you proposed does not remove the
> > need to use ASM_CALL_CONSTRAINT if we want to confine the "asm with
> > call inside" between frame setup/teardown insns? Is it possible to
> > invent similar clobber (unimaginatively called "stack", perhaps) that
> > would prevent scheduler from moving asm to the wrong place?
>
> I don't understand why would one want to avoid moving such inline asms
> there, the profiler can be called from there too and if a function
> doesn't use a red zone and the inline asm restores all registers except
> those explicitly clobbered in the clobbers, I think such calls can be done
> pretty much everywhere.  Sure, frame pointers might miss one frame, but
> frame pointer reliability for backtraces is abysmal anyway.
> But I'm not aware of a testcase where we would actually move inline asm
> there either (at least not on x86).  Is that some known problem (and then
> why?) or just theoretical issue?

Please see [1]:

/*
 * This output constraint should be used for any inline asm which has a "call"
 * instruction.  Otherwise the asm may be inserted before the frame pointer
 * gets set up by the containing function.  If you forget to do this, objtool
 * may print a "call without frame pointer save/setup" warning.
 */
register unsigned long current_stack_pointer asm(_ASM_SP);
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)

Perhaps HPA can say some more?

[1] 
https://elixir.bootlin.com/linux/v6.11.6/source/arch/x86/include/asm/asm.h#L223

> Or do you want a new clobber which will automatically add all call clobbered
> registers to the clobbers?  That might be useful, although in case where
> one compiler can support multiple call ABIs one needs to pick one; would
> that stand for the ABI of the current function, or something else?

No, functions called from asm are not ABI compliant functions.

Uros.

Reply via email to