|
5 | 5 | package gc
|
6 | 6 |
|
7 | 7 | import (
|
8 |
| - "cmd/compile/internal/ssa" |
9 | 8 | "cmd/internal/obj"
|
10 | 9 | "cmd/internal/sys"
|
11 | 10 | "fmt"
|
@@ -400,9 +399,9 @@ func compile(fn *Node) {
|
400 | 399 | }
|
401 | 400 |
|
402 | 401 | // Build an SSA backend function.
|
403 |
| - var ssafn *ssa.Func |
404 |
| - if shouldssa(Curfn) { |
405 |
| - ssafn = buildssa(Curfn) |
| 402 | + ssafn := buildssa(Curfn) |
| 403 | + if nerrors != 0 { |
| 404 | + return |
406 | 405 | }
|
407 | 406 |
|
408 | 407 | continpc = nil
|
@@ -478,83 +477,12 @@ func compile(fn *Node) {
|
478 | 477 | }
|
479 | 478 | }
|
480 | 479 |
|
481 |
| - if ssafn != nil { |
482 |
| - genssa(ssafn, ptxt, gcargs, gclocals) |
483 |
| - ssafn.Free() |
484 |
| - } else { |
485 |
| - genlegacy(ptxt, gcargs, gclocals) |
486 |
| - } |
| 480 | + genssa(ssafn, ptxt, gcargs, gclocals) |
| 481 | + ssafn.Free() |
487 | 482 | }
|
488 | 483 |
|
489 | 484 | type symByName []*Sym
|
490 | 485 |
|
491 | 486 | func (a symByName) Len() int { return len(a) }
|
492 | 487 | func (a symByName) Less(i, j int) bool { return a[i].Name < a[j].Name }
|
493 | 488 | func (a symByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
494 |
| - |
495 |
| -// genlegacy compiles Curfn using the legacy non-SSA code generator. |
496 |
| -func genlegacy(ptxt *obj.Prog, gcargs, gclocals *Sym) { |
497 |
| - Genlist(Curfn.Func.Enter) |
498 |
| - Genlist(Curfn.Nbody) |
499 |
| - gclean() |
500 |
| - checklabels() |
501 |
| - if nerrors != 0 { |
502 |
| - return |
503 |
| - } |
504 |
| - if Curfn.Func.Endlineno != 0 { |
505 |
| - lineno = Curfn.Func.Endlineno |
506 |
| - } |
507 |
| - |
508 |
| - if Curfn.Type.Results().NumFields() != 0 { |
509 |
| - Ginscall(throwreturn, 0) |
510 |
| - } |
511 |
| - |
512 |
| - ginit() |
513 |
| - |
514 |
| - // TODO: Determine when the final cgen_ret can be omitted. Perhaps always? |
515 |
| - cgen_ret(nil) |
516 |
| - |
517 |
| - if hasdefer { |
518 |
| - // deferreturn pretends to have one uintptr argument. |
519 |
| - // Reserve space for it so stack scanner is happy. |
520 |
| - if Maxarg < int64(Widthptr) { |
521 |
| - Maxarg = int64(Widthptr) |
522 |
| - } |
523 |
| - } |
524 |
| - |
525 |
| - gclean() |
526 |
| - if nerrors != 0 { |
527 |
| - return |
528 |
| - } |
529 |
| - |
530 |
| - Pc.As = obj.ARET // overwrite AEND |
531 |
| - Pc.Lineno = lineno |
532 |
| - |
533 |
| - fixjmp(ptxt) |
534 |
| - if Debug['N'] == 0 || Debug['R'] != 0 || Debug['P'] != 0 { |
535 |
| - regopt(ptxt) |
536 |
| - nilopt(ptxt) |
537 |
| - } |
538 |
| - |
539 |
| - Thearch.Expandchecks(ptxt) |
540 |
| - |
541 |
| - allocauto(ptxt) |
542 |
| - |
543 |
| - setlineno(Curfn) |
544 |
| - if Stksize+Maxarg > 1<<31 { |
545 |
| - Yyerror("stack frame too large (>2GB)") |
546 |
| - return |
547 |
| - } |
548 |
| - |
549 |
| - // Emit garbage collection symbols. |
550 |
| - liveness(Curfn, ptxt, gcargs, gclocals) |
551 |
| - |
552 |
| - Thearch.Defframe(ptxt) |
553 |
| - |
554 |
| - if Debug['f'] != 0 { |
555 |
| - frame(0) |
556 |
| - } |
557 |
| - |
558 |
| - // Remove leftover instrumentation from the instruction stream. |
559 |
| - removevardef(ptxt) |
560 |
| -} |
0 commit comments