-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/compile: framepointer + duffzero generates weird (+bad?) code #16013
Comments
Found it. There is this code (cmd/internal/obj/x86/asm6.go):
I'm not sure why this is necessary. Leaf routines have the same issue (they could, but don't, do any BP adjustment) and we don't insert this special code for them. |
Well, it's necessary for the reason the comment says. We need a BP if you want to see who's calling duffcopy/duffzero. For leaf routines, I thought it was just functions with a zero-sized frame that didn't do BP adjustment, which is a subset of leaf functions, but not all of them. I consider not doing BP adjustment for these a bug. It's just an unfortunate consequence of our rule to avoid adding BPs to sensitive assembly functions. But for these we still could do BP adjustment in the function prologue, but we really can't do BP adjustment in duffcopy/duffzero. |
Right, it's just frameless leaf functions that don't do BP adjustment. Do we have to worry about signal handlers? They could clobber values on the wrong side of SP. Or do we always run with a sigaltstack set up? |
We always run with an alternate signal stack (otherwise receiving the signal would overrun the small goroutine stack). |
Ok, I'll close this then. Ugly, but probably not buggy. |
Without framepointers, the zeroing of x is done with:
With framepointers on, however, there's some extra weird code on there:
I'm not sure what this code is about or where in the compiler it comes from. I'm investigating. Some sort of pretend framepointer link for duffzero? It doesn't seem necessary, duffzero is a leaf routine.
The fact that it is writing on the wrong side of
%rsp
scares me.Also check duffcopy.
@aclements
The text was updated successfully, but these errors were encountered: