Skip to content

Commit 167e381

Browse files
committed
cmd/compile: make ssa compilation unconditional
Rip out the code that allows SSA to be used conditionally. No longer exists: ssa=0 flag GOSSAHASH GOSSAPKG SSATEST GOSSAFUNC now only controls the printing of the IR/html. Still need to rip out all of the old backend. It should no longer be callable after this CL. Update #16357 Change-Id: Ib30cc18fba6ca52232c41689ba610b0a94aa74f5 Reviewed-on: https://go-review.googlesource.com/29155 Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Josh Bleecher Snyder <[email protected]>
1 parent eed061f commit 167e381

File tree

18 files changed

+68
-256
lines changed

18 files changed

+68
-256
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
684684
p.To.Offset = off
685685
case ssa.OpAMD64MOVOconst:
686686
if v.AuxInt != 0 {
687-
v.Unimplementedf("MOVOconst can only do constant=0")
687+
v.Fatalf("MOVOconst can only do constant=0")
688688
}
689689
r := gc.SSARegNum(v)
690690
opregreg(x86.AXORPS, r, r)
@@ -705,7 +705,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
705705
}
706706
case ssa.OpLoadReg:
707707
if v.Type.IsFlags() {
708-
v.Unimplementedf("load flags not implemented: %v", v.LongString())
708+
v.Fatalf("load flags not implemented: %v", v.LongString())
709709
return
710710
}
711711
p := gc.Prog(loadByType(v.Type))
@@ -725,7 +725,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
725725

726726
case ssa.OpStoreReg:
727727
if v.Type.IsFlags() {
728-
v.Unimplementedf("store flags not implemented: %v", v.LongString())
728+
v.Fatalf("store flags not implemented: %v", v.LongString())
729729
return
730730
}
731731
p := gc.Prog(storeByType(v.Type))
@@ -1031,7 +1031,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
10311031
p.To.Reg = gc.SSARegNum(v.Args[0])
10321032
gc.AddAux(&p.To, v)
10331033
default:
1034-
v.Unimplementedf("genValue not implemented: %s", v.LongString())
1034+
v.Fatalf("genValue not implemented: %s", v.LongString())
10351035
}
10361036
}
10371037

@@ -1145,6 +1145,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
11451145
}
11461146

11471147
default:
1148-
b.Unimplementedf("branch not implemented: %s. Control: %s", b.LongString(), b.Control.LongString())
1148+
b.Fatalf("branch not implemented: %s. Control: %s", b.LongString(), b.Control.LongString())
11491149
}
11501150
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
201201
// nothing to do
202202
case ssa.OpLoadReg:
203203
if v.Type.IsFlags() {
204-
v.Unimplementedf("load flags not implemented: %v", v.LongString())
204+
v.Fatalf("load flags not implemented: %v", v.LongString())
205205
return
206206
}
207207
p := gc.Prog(loadByType(v.Type))
@@ -222,7 +222,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
222222
gc.CheckLoweredPhi(v)
223223
case ssa.OpStoreReg:
224224
if v.Type.IsFlags() {
225-
v.Unimplementedf("store flags not implemented: %v", v.LongString())
225+
v.Fatalf("store flags not implemented: %v", v.LongString())
226226
return
227227
}
228228
p := gc.Prog(storeByType(v.Type))
@@ -958,7 +958,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
958958
case ssa.OpARMInvertFlags:
959959
v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString())
960960
default:
961-
v.Unimplementedf("genValue not implemented: %s", v.LongString())
961+
v.Fatalf("genValue not implemented: %s", v.LongString())
962962
}
963963
}
964964

@@ -1056,6 +1056,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
10561056
}
10571057

10581058
default:
1059-
b.Unimplementedf("branch not implemented: %s. Control: %s", b.LongString(), b.Control.LongString())
1059+
b.Fatalf("branch not implemented: %s. Control: %s", b.LongString(), b.Control.LongString())
10601060
}
10611061
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
206206
// nothing to do
207207
case ssa.OpLoadReg:
208208
if v.Type.IsFlags() {
209-
v.Unimplementedf("load flags not implemented: %v", v.LongString())
209+
v.Fatalf("load flags not implemented: %v", v.LongString())
210210
return
211211
}
212212
p := gc.Prog(loadByType(v.Type))
@@ -227,7 +227,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
227227
gc.CheckLoweredPhi(v)
228228
case ssa.OpStoreReg:
229229
if v.Type.IsFlags() {
230-
v.Unimplementedf("store flags not implemented: %v", v.LongString())
230+
v.Fatalf("store flags not implemented: %v", v.LongString())
231231
return
232232
}
233233
p := gc.Prog(storeByType(v.Type))
@@ -884,7 +884,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
884884
case ssa.OpARM64InvertFlags:
885885
v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString())
886886
default:
887-
v.Unimplementedf("genValue not implemented: %s", v.LongString())
887+
v.Fatalf("genValue not implemented: %s", v.LongString())
888888
}
889889
}
890890

@@ -982,6 +982,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
982982
}
983983

984984
default:
985-
b.Unimplementedf("branch not implemented: %s. Control: %s", b.LongString(), b.Control.LongString())
985+
b.Fatalf("branch not implemented: %s. Control: %s", b.LongString(), b.Control.LongString())
986986
}
987987
}

src/cmd/compile/internal/gc/main.go

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ func Main() {
208208
flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to `file`")
209209
flag.StringVar(&memprofile, "memprofile", "", "write memory profile to `file`")
210210
flag.Int64Var(&memprofilerate, "memprofilerate", 0, "set runtime.MemProfileRate to `rate`")
211-
flag.BoolVar(&ssaEnabled, "ssa", true, "use SSA backend to generate code")
212211
flag.StringVar(&benchfile, "bench", "", "append benchmark times to `file`")
213212
obj.Flagparse(usage)
214213

src/cmd/compile/internal/gc/pgen.go

+5-77
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package gc
66

77
import (
8-
"cmd/compile/internal/ssa"
98
"cmd/internal/obj"
109
"cmd/internal/sys"
1110
"fmt"
@@ -400,9 +399,9 @@ func compile(fn *Node) {
400399
}
401400

402401
// 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
406405
}
407406

408407
continpc = nil
@@ -478,83 +477,12 @@ func compile(fn *Node) {
478477
}
479478
}
480479

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()
487482
}
488483

489484
type symByName []*Sym
490485

491486
func (a symByName) Len() int { return len(a) }
492487
func (a symByName) Less(i, j int) bool { return a[i].Name < a[j].Name }
493488
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

Comments
 (0)