]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: more ssa config flags
authorKeith Randall <khr@golang.org>
Fri, 4 Mar 2016 06:06:57 +0000 (22:06 -0800)
committerKeith Randall <khr@golang.org>
Fri, 4 Mar 2016 19:03:12 +0000 (19:03 +0000)
To turn ssa compilation on or off altogether, use
-ssa=1 or -ssa=0.  Default is on.

To turn on or off consistency checks, do
-d=ssa/check/on or -d=ssa/check/off.  Default is on for now.

Change-Id: I277e0311f538981c8b9c62e7b7382a0c8755ce4c
Reviewed-on: https://go-review.googlesource.com/20217
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/gc/lex.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/compile.go

index 6509e83c92e18fe5e24f8585a4c991dcc4b7e0e4..3fa876ad40f6574004f9e16549915239f4f8df4f 100644 (file)
@@ -231,6 +231,7 @@ func Main() {
        obj.Flagstr("cpuprofile", "write cpu profile to `file`", &cpuprofile)
        obj.Flagstr("memprofile", "write memory profile to `file`", &memprofile)
        obj.Flagint64("memprofilerate", "set runtime.MemProfileRate to `rate`", &memprofilerate)
+       flag.BoolVar(&ssaEnabled, "ssa", true, "use SSA backend to generate code")
        obj.Flagparse(usage)
 
        if flag_dynlink {
index f83b88d79e0813fb09a4797f2a03ddc9df2a9a39..615ec6e6eb1d96465d3b15df95ce7bd998418beb 100644 (file)
@@ -17,6 +17,8 @@ import (
        "cmd/internal/obj/x86"
 )
 
+var ssaEnabled = true
+
 // Smallest possible faulting page at address zero.
 const minZeroPage = 4096
 
@@ -36,6 +38,9 @@ func shouldssa(fn *Node) bool {
        if Thearch.Thestring != "amd64" {
                return false
        }
+       if !ssaEnabled {
+               return false
+       }
 
        // Environment variable control of SSA CG
        // 1. IF GOSSAFUNC == current function name THEN
index 5a13b147fc81b11b3867ebe52ec269bc166bdd0a..40830c94192a4825d626c3417cf1a32610a3a90f 100644 (file)
@@ -40,7 +40,9 @@ func Compile(f *Func) {
        // Run all the passes
        printFunc(f)
        f.Config.HTML.WriteFunc("start", f)
-       checkFunc(f)
+       if checkEnabled {
+               checkFunc(f)
+       }
        const logMemStats = false
        for _, p := range passes {
                if !f.Config.optimize && !p.required {
@@ -93,7 +95,9 @@ func Compile(f *Func) {
                                f.logStat("TIME(ns):BYTES:ALLOCS", time, nBytes, nAllocs)
                        }
                }
-               checkFunc(f)
+               if checkEnabled {
+                       checkFunc(f)
+               }
        }
 
        // Squash error printing defer
@@ -112,6 +116,9 @@ type pass struct {
        test     int  // pass-specific ad-hoc option, perhaps useful in development
 }
 
+// Run consistency checker between each phase
+var checkEnabled = true
+
 // PhaseOption sets the specified flag in the specified ssa phase,
 // returning empty string if this was successful or a string explaining
 // the error if it was not. A version of the phase name with "_"
@@ -120,6 +127,14 @@ type pass struct {
 // GO_GCFLAGS=-d=ssa/generic_cse/time,ssa/generic_cse/stats,ssa/generic_cse/debug=3 ./make.bash ...
 //
 func PhaseOption(phase, flag string, val int) string {
+       if phase == "check" && flag == "on" {
+               checkEnabled = val != 0
+               return ""
+       }
+       if phase == "check" && flag == "off" {
+               checkEnabled = val == 0
+               return ""
+       }
        underphase := strings.Replace(phase, "_", " ", -1)
        for i, p := range passes {
                if p.name == phase || p.name == underphase {