p.pos = pos
return p
}
-
-var RegFP *Name
for _, v := range b.Values {
if n, ok := v.Aux.(*ir.Name); ok {
switch n.Class {
- case ir.PPARAM, ir.PPARAMOUT:
- // Don't modify RegFP; it is a global.
- if n != ir.RegFP {
- n.SetUsed(true)
- }
- case ir.PAUTO:
+ case ir.PPARAM, ir.PPARAMOUT, ir.PAUTO:
n.SetUsed(true)
}
}
if v != nil {
return v
}
- if n == ir.RegFP {
- // Special arg that points to the frame pointer (Used by ORECOVER).
- return s.entryNewValue2A(ssa.OpLocalAddr, t, n, s.sp, s.startmem)
- }
s.Fatalf("addr of undeclared ONAME %v. declared: %v", n, s.decladdrs)
return nil
case ir.PAUTO:
{"uint32tofloat64", funcTag, 117},
{"complex128div", funcTag, 118},
{"getcallerpc", funcTag, 119},
+ {"getcallersp", funcTag, 119},
{"racefuncenter", funcTag, 31},
{"racefuncexit", funcTag, 9},
{"raceread", funcTag, 31},
func complex128div(num complex128, den complex128) (quo complex128)
func getcallerpc() uintptr
+func getcallersp() uintptr
// race detection
func racefuncenter(uintptr)
s1.Def = s.Def
s1.Block = s.Block
}
-
- ir.RegFP = NewName(Lookup(".fp"))
- ir.RegFP.SetType(types.Types[types.TINT32])
- ir.RegFP.Class = ir.PPARAM
- ir.RegFP.SetUsed(true)
}
case ir.ORECOVER:
n := n.(*ir.CallExpr)
- return mkcall("gorecover", n.Type(), init, typecheck.NodAddr(ir.RegFP))
+ // Call gorecover with the FP of this frame.
+ // FP is equal to caller's SP plus FixedFrameSize().
+ var fp ir.Node = mkcall("getcallersp", types.Types[types.TUINTPTR], init)
+ if off := base.Ctxt.FixedFrameSize(); off != 0 {
+ fp = ir.NewBinaryExpr(fp.Pos(), ir.OADD, fp, ir.NewInt(off))
+ }
+ fp = ir.NewConvExpr(fp.Pos(), ir.OCONVNOP, types.NewPtr(types.Types[types.TINT32]), fp)
+ return mkcall("gorecover", n.Type(), init, fp)
case ir.OCFUNC:
return n