Skip to content

Commit 78052f4

Browse files
committed
cmd/compile: minor cleanup -- remove dead code conditional on test
It would fail now if it were turned on. Updsates #44816. Change-Id: I19d94f0cb2dd84271f5304c796d7c81e1e64af25 Reviewed-on: https://go-review.googlesource.com/c/go/+/301270 Trust: David Chase <[email protected]> Run-TryBot: David Chase <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent 7240a18 commit 78052f4

File tree

1 file changed

+24
-47
lines changed
  • src/cmd/compile/internal/ssagen

1 file changed

+24
-47
lines changed

src/cmd/compile/internal/ssagen/ssa.go

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,6 @@ const shareDeferExits = false
19301930
// It returns a BlockRet block that ends the control flow. Its control value
19311931
// will be set to the final memory state.
19321932
func (s *state) exit() *ssa.Block {
1933-
lateResultLowering := s.f.DebugTest
19341933
if s.hasdefer {
19351934
if s.hasOpenDefers {
19361935
if shareDeferExits && s.lastDeferExit != nil && len(s.openDefers) == s.lastDeferCount {
@@ -1951,56 +1950,34 @@ func (s *state) exit() *ssa.Block {
19511950
var m *ssa.Value
19521951
// Do actual return.
19531952
// These currently turn into self-copies (in many cases).
1954-
if lateResultLowering {
1955-
resultFields := s.curfn.Type().Results().FieldSlice()
1956-
results := make([]*ssa.Value, len(resultFields)+1, len(resultFields)+1)
1957-
m = s.newValue0(ssa.OpMakeResult, s.f.OwnAux.LateExpansionResultType())
1958-
// Store SSAable and heap-escaped PPARAMOUT variables back to stack locations.
1959-
for i, f := range resultFields {
1960-
n := f.Nname.(*ir.Name)
1961-
s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem())
1962-
if s.canSSA(n) { // result is in some SSA variable
1963-
results[i] = s.variable(n, n.Type())
1964-
} else if !n.OnStack() { // result is actually heap allocated
1965-
ha := s.expr(n.Heapaddr)
1966-
s.instrumentFields(n.Type(), ha, instrumentRead)
1967-
results[i] = s.newValue2(ssa.OpDereference, n.Type(), ha, s.mem())
1968-
} else { // result is not SSA-able; not escaped, so not on heap, but too large for SSA.
1969-
// Before register ABI this ought to be a self-move, home=dest,
1970-
// With register ABI, it's still a self-move if parameter is on stack (i.e., too big or overflowed)
1971-
results[i] = s.newValue2(ssa.OpDereference, n.Type(), s.addr(n), s.mem())
1972-
}
1953+
resultFields := s.curfn.Type().Results().FieldSlice()
1954+
results := make([]*ssa.Value, len(resultFields)+1, len(resultFields)+1)
1955+
m = s.newValue0(ssa.OpMakeResult, s.f.OwnAux.LateExpansionResultType())
1956+
// Store SSAable and heap-escaped PPARAMOUT variables back to stack locations.
1957+
for i, f := range resultFields {
1958+
n := f.Nname.(*ir.Name)
1959+
s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem())
1960+
if s.canSSA(n) { // result is in some SSA variable
1961+
results[i] = s.variable(n, n.Type())
1962+
} else if !n.OnStack() { // result is actually heap allocated
1963+
ha := s.expr(n.Heapaddr)
1964+
s.instrumentFields(n.Type(), ha, instrumentRead)
1965+
results[i] = s.newValue2(ssa.OpDereference, n.Type(), ha, s.mem())
1966+
} else { // result is not SSA-able; not escaped, so not on heap, but too large for SSA.
1967+
// Before register ABI this ought to be a self-move, home=dest,
1968+
// With register ABI, it's still a self-move if parameter is on stack (i.e., too big or overflowed)
1969+
results[i] = s.newValue2(ssa.OpDereference, n.Type(), s.addr(n), s.mem())
19731970
}
1971+
}
19741972

1975-
// Run exit code. Today, this is just racefuncexit, in -race mode.
1976-
// TODO(register args) this seems risky here with a register-ABI, but not clear it is right to do it earlier either.
1977-
// Spills in register allocation might just fix it.
1978-
s.stmtList(s.curfn.Exit)
1979-
1980-
results[len(results)-1] = s.mem()
1981-
m.AddArgs(results...)
1982-
} else {
1983-
// Store SSAable and heap-escaped PPARAMOUT variables back to stack locations.
1984-
for _, f := range s.curfn.Type().Results().FieldSlice() {
1985-
n := f.Nname.(*ir.Name)
1986-
if s.canSSA(n) {
1987-
val := s.variable(n, n.Type())
1988-
s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem())
1989-
s.store(n.Type(), s.decladdrs[n], val)
1990-
} else if !n.OnStack() {
1991-
s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem())
1992-
s.move(n.Type(), s.decladdrs[n], s.expr(n.Heapaddr))
1993-
} // else, on stack but too large to SSA, the result is already in its destination by construction, so no store needed.
1994-
1995-
// TODO: if (SSA) val is ever spilled, we'd like to use the PPARAMOUT slot for spilling it. That won't happen currently.
1996-
}
1973+
// Run exit code. Today, this is just racefuncexit, in -race mode.
1974+
// TODO(register args) this seems risky here with a register-ABI, but not clear it is right to do it earlier either.
1975+
// Spills in register allocation might just fix it.
1976+
s.stmtList(s.curfn.Exit)
19971977

1998-
// Run exit code. Today, this is just racefuncexit, in -race mode.
1999-
s.stmtList(s.curfn.Exit)
1978+
results[len(results)-1] = s.mem()
1979+
m.AddArgs(results...)
20001980

2001-
// Do actual return.
2002-
m = s.mem()
2003-
}
20041981
b = s.endBlock()
20051982
b.Kind = ssa.BlockRet
20061983
b.SetControl(m)

0 commit comments

Comments
 (0)