Skip to content

Commit

Permalink
cmd/compile: some minor cleanups
Browse files Browse the repository at this point in the history
Change-Id: Icdf3320814ad4a86a5ae532f4fcb899da3f46ae3
Reviewed-on: https://go-review.googlesource.com/c/go/+/248186
Trust: David Chase <[email protected]>
Run-TryBot: David Chase <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
  • Loading branch information
dr2chase committed Oct 9, 2020
1 parent 33511fb commit 51690f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
12 changes: 3 additions & 9 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -4375,9 +4375,7 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {

switch n.Op {
case OCALLFUNC:
if k != callDeferStack && ssa.LateCallExpansionEnabledWithin(s.f) {
testLateExpansion = true
}
testLateExpansion = k != callDeferStack && ssa.LateCallExpansionEnabledWithin(s.f)
if k == callNormal && fn.Op == ONAME && fn.Class() == PFUNC {
sym = fn.Sym
break
Expand All @@ -4392,9 +4390,7 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
if fn.Op != ODOTMETH {
s.Fatalf("OCALLMETH: n.Left not an ODOTMETH: %v", fn)
}
if k != callDeferStack && ssa.LateCallExpansionEnabledWithin(s.f) {
testLateExpansion = true
}
testLateExpansion = k != callDeferStack && ssa.LateCallExpansionEnabledWithin(s.f)
if k == callNormal {
sym = fn.Sym
break
Expand All @@ -4406,9 +4402,7 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
if fn.Op != ODOTINTER {
s.Fatalf("OCALLINTER: n.Left not an ODOTINTER: %v", fn.Op)
}
if k != callDeferStack && ssa.LateCallExpansionEnabledWithin(s.f) {
testLateExpansion = true
}
testLateExpansion = k != callDeferStack && ssa.LateCallExpansionEnabledWithin(s.f)
var iclosure *ssa.Value
iclosure, rcvr = s.getClosureAndRcvr(fn)
if k == callNormal {
Expand Down
15 changes: 10 additions & 5 deletions src/cmd/compile/internal/ssa/expand_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func expandCalls(f *Func) {
hiOffset = 4
}

pairTypes := func(et types.EType) (tHi, tLo *types.Type) {
// intPairTypes returns the pair of 32-bit int types needed to encode a 64-bit integer type on a target
// that has no 64-bit integer registers.
intPairTypes := func(et types.EType) (tHi, tLo *types.Type) {
tHi = tUint32
if et == types.TINT64 {
tHi = tInt32
Expand Down Expand Up @@ -147,8 +149,8 @@ func expandCalls(f *Func) {
}
}

// storeArg converts stores of SSA-able aggregates into a series of stores of smaller types into
// individual parameter slots.
// storeArg converts stores of SSA-able aggregate arguments (passed to a call) into a series of stores of
// smaller types into individual parameter slots.
// TODO when registers really arrive, must also decompose anything split across two registers or registers and memory.
var storeArg func(pos src.XPos, b *Block, a *Value, t *types.Type, offset int64, mem *Value) *Value
storeArg = func(pos src.XPos, b *Block, a *Value, t *types.Type, offset int64, mem *Value) *Value {
Expand All @@ -165,7 +167,7 @@ func expandCalls(f *Func) {
return storeArg(pos, b, a.Args[0], t.Elem(), offset, mem)

case OpInt64Make:
tHi, tLo := pairTypes(t.Etype)
tHi, tLo := intPairTypes(t.Etype)
mem = storeArg(pos, b, a.Args[0], tHi, offset+hiOffset, mem)
return storeArg(pos, b, a.Args[1], tLo, offset+lowOffset, mem)
}
Expand Down Expand Up @@ -207,7 +209,7 @@ func expandCalls(f *Func) {
if t.Width == regSize {
break
}
tHi, tLo := pairTypes(t.Etype)
tHi, tLo := intPairTypes(t.Etype)
sel := src.Block.NewValue1(pos, OpInt64Hi, tHi, src)
mem = splitStore(dst, sel, mem, v, tHi, offset+hiOffset, firstStorePos)
firstStorePos = firstStorePos.WithNotStmt()
Expand Down Expand Up @@ -261,6 +263,9 @@ func expandCalls(f *Func) {
return x
}

// rewriteArgs removes all the Args from a call and converts the call args into appropriate
// stores (or later, register movement). Extra args for interface and closure calls are ignored,
// but removed.
rewriteArgs := func(v *Value, firstArg int) *Value {
// Thread the stores on the memory arg
aux := v.Aux.(*AuxCall)
Expand Down

0 comments on commit 51690f7

Please sign in to comment.