Skip to content
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
Open

cmd/asm, runtime: textflag for CABI #21004

crawshaw opened this issue Jul 13, 2017 · 3 comments
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@crawshaw
Copy link
Member

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
@bradfitz bradfitz added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jul 13, 2017
@randall77
Copy link
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?

@aclements
Copy link
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).

@crawshaw
Copy link
Member Author

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
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 13, 2018
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants