1
0
mirror of https://github.com/golang/go synced 2024-11-17 05:54:46 -07:00

cmd/compile: late call expansion for rtcall

Change-Id: I0708c9d649d8a579857330b68d9fbcbbeced29e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/248189
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
David Chase 2020-08-12 15:46:19 -04:00
parent bb46b60d29
commit eb67eab861

View File

@ -4353,7 +4353,6 @@ func (s *state) openDeferExit() {
} else {
s.vars[&memVar] = call
}
// Make sure that the stack slots with pointers are kept live
// through the call (which is a pre-emption point). Also, we will
// use the first call of the last defer exit to compute liveness
@ -5076,15 +5075,22 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
s.prevCall = nil
// Write args to the stack
off := Ctxt.FixedFrameSize()
testLateExpansion := ssa.LateCallExpansionEnabledWithin(s.f)
var ACArgs []ssa.Param
var ACResults []ssa.Param
var callArgs []*ssa.Value
for _, arg := range args {
t := arg.Type
off = Rnd(off, t.Alignment())
ptr := s.constOffPtrSP(t.PtrTo(), off)
size := t.Size()
ACArgs = append(ACArgs, ssa.Param{Type: t, Offset: int32(off)})
s.store(t, ptr, arg)
if testLateExpansion {
callArgs = append(callArgs, arg)
} else {
ptr := s.constOffPtrSP(t.PtrTo(), off)
s.store(t, ptr, arg)
}
off += size
}
off = Rnd(off, int64(Widthreg))
@ -5098,8 +5104,17 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
}
// Issue call
call := s.newValue1A(ssa.OpStaticCall, types.TypeMem, ssa.StaticAuxCall(fn, ACArgs, ACResults), s.mem())
s.vars[&memVar] = call
var call *ssa.Value
aux := ssa.StaticAuxCall(fn, ACArgs, ACResults)
if testLateExpansion {
callArgs = append(callArgs, s.mem())
call = s.newValue0A(ssa.OpStaticLECall, aux.LateExpansionResultType(), aux)
call.AddArgs(callArgs...)
s.vars[&memVar] = s.newValue1I(ssa.OpSelectN, types.TypeMem, int64(len(ACResults)), call)
} else {
call = s.newValue1A(ssa.OpStaticCall, types.TypeMem, aux, s.mem())
s.vars[&memVar] = call
}
if !returns {
// Finish block
@ -5115,11 +5130,24 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
// Load results
res := make([]*ssa.Value, len(results))
for i, t := range results {
off = Rnd(off, t.Alignment())
ptr := s.constOffPtrSP(types.NewPtr(t), off)
res[i] = s.load(t, ptr)
off += t.Size()
if testLateExpansion {
for i, t := range results {
off = Rnd(off, t.Alignment())
if canSSAType(t) {
res[i] = s.newValue1I(ssa.OpSelectN, t, int64(i), call)
} else {
addr := s.newValue1I(ssa.OpSelectNAddr, types.NewPtr(t), int64(i), call)
res[i] = s.rawLoad(t, addr)
}
off += t.Size()
}
} else {
for i, t := range results {
off = Rnd(off, t.Alignment())
ptr := s.constOffPtrSP(types.NewPtr(t), off)
res[i] = s.load(t, ptr)
off += t.Size()
}
}
off = Rnd(off, int64(Widthptr))