@@ -1930,7 +1930,6 @@ const shareDeferExits = false
1930
1930
// It returns a BlockRet block that ends the control flow. Its control value
1931
1931
// will be set to the final memory state.
1932
1932
func (s * state ) exit () * ssa.Block {
1933
- lateResultLowering := s .f .DebugTest
1934
1933
if s .hasdefer {
1935
1934
if s .hasOpenDefers {
1936
1935
if shareDeferExits && s .lastDeferExit != nil && len (s .openDefers ) == s .lastDeferCount {
@@ -1951,56 +1950,34 @@ func (s *state) exit() *ssa.Block {
1951
1950
var m * ssa.Value
1952
1951
// Do actual return.
1953
1952
// 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 ())
1973
1970
}
1971
+ }
1974
1972
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 )
1997
1977
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 ... )
2000
1980
2001
- // Do actual return.
2002
- m = s .mem ()
2003
- }
2004
1981
b = s .endBlock ()
2005
1982
b .Kind = ssa .BlockRet
2006
1983
b .SetControl (m )
0 commit comments