pass: ensure frame pointer register is saved (#174)
Currently `avo` uses `BP` as a standard general-purpose register. However, `BP` is used for the frame pointer and should be callee-save. Under some circumstances, the Go assembler will do this automatically, but not always. At the moment `avo` can produce code that clobbers the `BP` register. Since Go 1.16 this code will also fail a new `go vet` check. This PR provides a (currently sub-optimal) fix for the issue. It introduces an `EnsureBasePointerCalleeSaved` pass which will check if the base pointer is written to by a function, and if so will artificially ensure that the function has a non-zero frame size. This will trigger the Go assembler to automatically save and restore the BP register. In addition, we update the `asmdecl` tool to `asmvet`, which includes the `framepointer` vet check. Updates #156
This commit is contained in:
committed by
GitHub
parent
4592e16ebb
commit
f295bde84c
@@ -15,6 +15,9 @@ import (
|
||||
// Sizes provides type sizes used by the standard Go compiler on amd64.
|
||||
var Sizes = types.SizesFor("gc", "amd64")
|
||||
|
||||
// PointerSize is the size of a pointer on amd64.
|
||||
var PointerSize = Sizes.Sizeof(types.Typ[types.UnsafePointer])
|
||||
|
||||
// Basic represents a primitive/basic type at a given memory address.
|
||||
type Basic struct {
|
||||
Addr operand.Mem
|
||||
|
||||
Reference in New Issue
Block a user