New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/asm, runtime: textflag for CABI #21004

Open
crawshaw opened this Issue Jul 13, 2017 · 3 comments

Comments

Projects
None yet
7 participants
@crawshaw
Contributor

crawshaw commented Jul 13, 2017

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

@bradfitz bradfitz added this to the Go1.10 milestone Jul 13, 2017

@randall77

This comment has been minimized.

Contributor

randall77 commented Jul 14, 2017

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?

@aclements

This comment has been minimized.

Member

aclements commented Jul 17, 2017

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).

@crawshaw

This comment has been minimized.

Contributor

crawshaw commented Jul 19, 2017

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.

@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017

@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Unplanned Jun 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment