Re: [tip: x86/asm] x86/asm: Make ASM_CALL_CONSTRAINT conditional on frame pointers

From: Linus Torvalds
Date: Tue Mar 04 2025 - 15:41:40 EST


On Tue, 4 Mar 2025 at 10:13, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Does clang even need it?

Bah. Yes it does. I may not have clang sources to try to look at, but
I can do a test-build.

Anyway, I do think it would be better to make this compiler-specific,
and keep gcc using the old tested case that works well regardless of
whether frame pointers are enabled or not, since it doesn't _care_.

And I think there's a better way to deal with the whole "generate
better code when not needed" too, if clang really has to have that
disgusting __builtin_frame_pointer() thing that then has problems when
frame pointers aren't enabled.

IOW, you could do something pointless like

extern int unused_variable;
#define ASM_CALL_CONSTRAINT "+m" (unused_variable)

which generates a dependency that doesn't matter, and then doesn't
then require preprocessor hacks for when it is empty.

So I *think* the patch could be something like

- move the define to <asm/compiler-xyzzy,.h>

- for gcc, use the old tested code

- for clang, use the "either __builtin_frame_pointer(0) or dummy
dependency" thing

- have big comments about it, because our historical changelogs
clearly are not accurate wrt this all.

Linus