Skip to content

cmd/asm, runtime: textflag for CABI #21004

Open

Description

@crawshaw

The runtime assembly code includes many functions that are called from outside the runtime and are called with the C ABI. This means the functions first have to save callee-saved registers manually.

For example, see runtime·sigtramp in sys_linux_*.s.

Once after diagnosing a callee-save error, I failed to save all the callee-save registers. This meant months later, @aclements had to go through the same long debugging session. We could make this more robust (and potentially make our assembly a bit easier to read) by adding a CABI text flag, and have the assembler insert code for saving and restoring registers.

cc @ianlancetaylor

Activity

  1. added this to the Go1.10 milestone on Jul 13, 2017
  2. added
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Jul 13, 2017
  3. randall77 commented on Jul 14, 2017

    @randall77
    Contributor

    It's not just enough to want to save them, we need a place to save them. Where do we save them (xx(SP))? Do we need to reserve space for them, or does this flag do so?

  4. aclements commented on Jul 17, 2017

    @aclements
    Member

    Do we need to reserve space for them, or does this flag do so?

    I think we would want the flag to automatically reserve space for them, just like we do for the frame pointer on x86 and the saved LR on LR machines.

    This means the functions first have to save callee-saved registers manually.

    Would this flag save all of the callee-save registers? That's potentially a lot of registers that aren't actually going to be clobbered. Where these bugs are really insidious are the C callee-save registers that are used implicitly by obj (so they never explicitly appear in the assembly).

  5. crawshaw commented on Jul 19, 2017

    @crawshaw
    MemberAuthor

    The cases that I can think of are not hot functions, so I would be happy saving all callee-save registers. Though I agree just the invisible obj registers would be enough to let me breath easy.

    As to where, reserved stack space. These are functions called from C, so there's stack to use.

  6. modified the milestones: Go1.10, Go1.11 on Nov 22, 2017
  7. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Jun 13, 2018
  8. removed
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions