@@ -4353,7 +4353,6 @@ func (s *state) openDeferExit() {
4353
4353
} else {
4354
4354
s .vars [& memVar ] = call
4355
4355
}
4356
-
4357
4356
// Make sure that the stack slots with pointers are kept live
4358
4357
// through the call (which is a pre-emption point). Also, we will
4359
4358
// 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 .
5076
5075
s .prevCall = nil
5077
5076
// Write args to the stack
5078
5077
off := Ctxt .FixedFrameSize ()
5078
+ testLateExpansion := ssa .LateCallExpansionEnabledWithin (s .f )
5079
5079
var ACArgs []ssa.Param
5080
5080
var ACResults []ssa.Param
5081
+ var callArgs []* ssa.Value
5082
+
5081
5083
for _ , arg := range args {
5082
5084
t := arg .Type
5083
5085
off = Rnd (off , t .Alignment ())
5084
- ptr := s .constOffPtrSP (t .PtrTo (), off )
5085
5086
size := t .Size ()
5086
5087
ACArgs = append (ACArgs , ssa.Param {Type : t , Offset : int32 (off )})
5087
- s .store (t , ptr , arg )
5088
+ if testLateExpansion {
5089
+ callArgs = append (callArgs , arg )
5090
+ } else {
5091
+ ptr := s .constOffPtrSP (t .PtrTo (), off )
5092
+ s .store (t , ptr , arg )
5093
+ }
5088
5094
off += size
5089
5095
}
5090
5096
off = Rnd (off , int64 (Widthreg ))
@@ -5098,8 +5104,17 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
5098
5104
}
5099
5105
5100
5106
// Issue call
5101
- call := s .newValue1A (ssa .OpStaticCall , types .TypeMem , ssa .StaticAuxCall (fn , ACArgs , ACResults ), s .mem ())
5102
- s .vars [& memVar ] = call
5107
+ var call * ssa.Value
5108
+ aux := ssa .StaticAuxCall (fn , ACArgs , ACResults )
5109
+ if testLateExpansion {
5110
+ callArgs = append (callArgs , s .mem ())
5111
+ call = s .newValue0A (ssa .OpStaticLECall , aux .LateExpansionResultType (), aux )
5112
+ call .AddArgs (callArgs ... )
5113
+ s .vars [& memVar ] = s .newValue1I (ssa .OpSelectN , types .TypeMem , int64 (len (ACResults )), call )
5114
+ } else {
5115
+ call = s .newValue1A (ssa .OpStaticCall , types .TypeMem , aux , s .mem ())
5116
+ s .vars [& memVar ] = call
5117
+ }
5103
5118
5104
5119
if ! returns {
5105
5120
// Finish block
@@ -5115,11 +5130,24 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
5115
5130
5116
5131
// Load results
5117
5132
res := make ([]* ssa.Value , len (results ))
5118
- for i , t := range results {
5119
- off = Rnd (off , t .Alignment ())
5120
- ptr := s .constOffPtrSP (types .NewPtr (t ), off )
5121
- res [i ] = s .load (t , ptr )
5122
- off += t .Size ()
5133
+ if testLateExpansion {
5134
+ for i , t := range results {
5135
+ off = Rnd (off , t .Alignment ())
5136
+ if canSSAType (t ) {
5137
+ res [i ] = s .newValue1I (ssa .OpSelectN , t , int64 (i ), call )
5138
+ } else {
5139
+ addr := s .newValue1I (ssa .OpSelectNAddr , types .NewPtr (t ), int64 (i ), call )
5140
+ res [i ] = s .rawLoad (t , addr )
5141
+ }
5142
+ off += t .Size ()
5143
+ }
5144
+ } else {
5145
+ for i , t := range results {
5146
+ off = Rnd (off , t .Alignment ())
5147
+ ptr := s .constOffPtrSP (types .NewPtr (t ), off )
5148
+ res [i ] = s .load (t , ptr )
5149
+ off += t .Size ()
5150
+ }
5123
5151
}
5124
5152
off = Rnd (off , int64 (Widthptr ))
5125
5153
0 commit comments