diff --git a/src/cmd/compile/internal/ssa/loopreschedchecks.go b/src/cmd/compile/internal/ssa/loopreschedchecks.go index 738c62607ad..1326fa5ee8e 100644 --- a/src/cmd/compile/internal/ssa/loopreschedchecks.go +++ b/src/cmd/compile/internal/ssa/loopreschedchecks.go @@ -246,8 +246,8 @@ func insertLoopReschedChecks(f *Func) { // mem1 := call resched (mem0) // goto header resched := f.fe.Syslook("goschedguarded") - // TODO(register args) -- will need more details - mem1 := sched.NewValue1A(bb.Pos, OpStaticCall, types.TypeMem, StaticAuxCall(resched, nil), mem0) + call := sched.NewValue1A(bb.Pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(resched, bb.Func.ABIDefault.ABIAnalyzeTypes(nil, nil, nil)), mem0) + mem1 := sched.NewValue1I(bb.Pos, OpSelectN, types.TypeMem, 0, call) sched.AddEdgeTo(h) headerMemPhi.AddArg(mem1) @@ -448,6 +448,16 @@ func findLastMems(f *Func) []*Value { if last == nil { b.Fatalf("no last store found - cycle?") } + + // If this is a tuple containing a mem, select just + // the mem. This will generate ops we don't need, but + // it's the easiest thing to do. + if last.Type.IsTuple() { + last = b.NewValue1(last.Pos, OpSelect1, types.TypeMem, last) + } else if last.Type.IsResults() { + last = b.NewValue1I(last.Pos, OpSelectN, types.TypeMem, int64(last.Type.NumFields()-1), last) + } + lastMems[b.ID] = last } return lastMems