Stream: project-inline-asm

Topic: alignstack


Amanieu (Dec 15 2019 at 18:54, on Zulip):

@Josh Triplett What are your thoughts on adding the alignstack attribute? I would name it something like uses_stack and make it required if your asm code pushes to the stack.

Josh Triplett (Dec 15 2019 at 19:03, on Zulip):

How much overhead does it add? Because that seems inconsistent with the safe-default approach used elsewhere, such as assuming earlyclobber and assuming clobbers of flags.

Josh Triplett (Dec 15 2019 at 19:03, on Zulip):

Could we just default to alignstack, and (optionally) add a nostack flag or similar?

Amanieu (Dec 15 2019 at 19:09, on Zulip):

It basically causes leaf functions to be treated as non-leaf functions.

Amanieu (Dec 15 2019 at 19:10, on Zulip):

Basically it adds 2 instructions to the functions for the esp adjustment at the start & end.

Amanieu (Dec 15 2019 at 19:10, on Zulip):

And that's only on x86_64.

Amanieu (Dec 15 2019 at 19:10, on Zulip):

I'm ok with reversing it to nostack.

Josh Triplett (Dec 15 2019 at 20:11, on Zulip):

That seems reasonable to me. In particular, if you have a tiny leaf function that just contains inline assembly, you'll probably mark the whole function #[inline] so that it can be inlined into its caller, which eliminates that same overhead.

Josh Triplett (Dec 15 2019 at 20:12, on Zulip):

And that seems like an excellent potential lint for future linting infrastructure that "understands" assembly: "it looks like this assembly could use nostack".

Last update: Apr 05 2020 at 00:45UTC