Commit b55eedd1 authored by Matthew Dempsky's avatar Matthew Dempsky

Revert "cmd/compile: cleanup nodpc and nodfp"

This reverts commit dcac984b.

Reason for revert: broke LR architectures (arm64, ppc64, s390x)

Change-Id: I531d311c9053e81503c8c78d6cf044b318fc828b
Reviewed-on: https://go-review.googlesource.com/99695
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent 010579c2
This diff is collapsed.
......@@ -22,7 +22,7 @@ func throwinit()
func panicwrap()
func gopanic(interface{})
func gorecover(uintptr) interface{}
func gorecover(*int32) interface{}
func goschedguarded()
func printbool(bool)
......
......@@ -2025,6 +2025,10 @@ func addrescapes(n *Node) {
// Nothing to do.
case ONAME:
if n == nodfp {
break
}
// if this is a tmpname (PAUTO), it was tagged by tmpname as not escaping.
// on PPARAM it means something different.
if n.Class() == PAUTO && n.Esc == EscNever {
......
......@@ -232,6 +232,8 @@ var writearchive bool
var Nacl bool
var nodfp *Node
var disable_checknil int
var autogeneratedPos src.XPos
......
......@@ -131,7 +131,12 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
for _, v := range b.Values {
if n, ok := v.Aux.(*Node); ok {
switch n.Class() {
case PAUTO, PPARAM, PPARAMOUT:
case PPARAM, PPARAMOUT:
// Don't modify nodfp; it is a global.
if n != nodfp {
n.Name.SetUsed(true)
}
case PAUTO:
n.Name.SetUsed(true)
}
}
......
......@@ -64,11 +64,21 @@ func instrument(fn *Node) {
}
if flag_race {
lno := lineno
// nodpc is the PC of the caller as extracted by
// getcallerpc. We use -widthptr(FP) for x86.
// BUG: this will not work on arm.
nodpc := *nodfp
nodpc.Type = types.Types[TUINTPTR]
nodpc.Xoffset = int64(-Widthptr)
savedLineno := lineno
lineno = src.NoXPos
fn.Func.Enter.Prepend(mkcall("racefuncenter", nil, nil, callerPC))
fn.Func.Exit.Append(mkcall("racefuncexit", nil, nil))
lineno = lno
nd := mkcall("racefuncenter", nil, nil, &nodpc)
fn.Func.Enter.Prepend(nd)
nd = mkcall("racefuncexit", nil, nil)
fn.Func.Exit.Append(nd)
fn.Func.Dcl = append(fn.Func.Dcl, &nodpc)
lineno = savedLineno
}
if Debug['W'] != 0 {
......
......@@ -1471,12 +1471,6 @@ func (s *state) expr(n *Node) *ssa.Value {
sym := funcsym(n.Sym).Linksym()
return s.entryNewValue1A(ssa.OpAddr, types.NewPtr(n.Type), sym, s.sb)
}
switch n {
case callerSP:
return s.newValue0(ssa.OpGetCallerSP, n.Type)
case callerPC:
return s.newValue0(ssa.OpGetCallerPC, n.Type)
}
if s.canSSA(n) {
return s.variable(n, n.Type)
}
......@@ -3474,6 +3468,10 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value {
if v != nil {
return v
}
if n == nodfp {
// Special arg that points to the frame pointer (Used by ORECOVER).
return s.entryNewValue1A(ssa.OpAddr, t, n, s.sp)
}
s.Fatalf("addr of undeclared ONAME %v. declared: %v", n, s.decladdrs)
return nil
case PAUTO:
......
......@@ -466,19 +466,8 @@ func finishUniverse() {
s1.Block = s.Block
}
callerSP = newname(lookup(".sp"))
callerSP.Type = types.Types[TUINTPTR]
callerSP.SetClass(PPARAM)
callerSP.Name.SetUsed(true)
callerPC = newname(lookup(".pc"))
callerPC.Type = types.Types[TUINTPTR]
callerPC.SetClass(PPARAM)
callerPC.Name.SetUsed(true)
nodfp = newname(lookup(".fp"))
nodfp.Type = types.Types[TINT32]
nodfp.SetClass(PPARAM)
nodfp.Name.SetUsed(true)
}
var (
// Pseudo variables that represent the caller's SP and PC, respectively.
callerSP *Node
callerPC *Node
)
......@@ -604,7 +604,7 @@ opswitch:
n = mkcall("gopanic", nil, init, n.Left)
case ORECOVER:
n = mkcall("gorecover", n.Type, init, callerSP)
n = mkcall("gorecover", n.Type, init, nod(OADDR, nodfp, nil))
case OCLOSUREVAR, OCFUNC:
n.SetAddable(true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment