]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: run deadcode before nilcheck for better statement relocation
authorDavid Chase <drchase@google.com>
Mon, 30 Sep 2019 15:12:29 +0000 (11:12 -0400)
committerDavid Chase <drchase@google.com>
Thu, 3 Oct 2019 21:12:13 +0000 (21:12 +0000)
Nilcheck would move statements from NilCheck values to others that
turned out were already dead, which leads to lost statements.  Better
to eliminate the dead code first.

One "error" is removed from test/prove.go because the code is
actually dead, and the additional deadcode pass removes it before
prove can run.

Change-Id: If75926ca1acbb59c7ab9c8ef14d60a02a0a94f8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/198479
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/compile/internal/ssa/compile.go
test/prove.go

index f061b624483b7b5950ab2165f94c0589ad131059..1a0a46c154ca6e080128e2e373e11af838f1b2d6 100644 (file)
@@ -409,6 +409,7 @@ var passes = [...]pass{
        {name: "opt deadcode", fn: deadcode, required: true}, // remove any blocks orphaned during opt
        {name: "generic cse", fn: cse},
        {name: "phiopt", fn: phiopt},
+       {name: "gcse deadcode", fn: deadcode, required: true}, // clean out after cse and phiopt
        {name: "nilcheckelim", fn: nilcheckelim},
        {name: "prove", fn: prove},
        {name: "fuse plain", fn: fusePlain},
index 6629982ba8558b5af7068c176bc28113a6f91ad8..00fc94e7219596a0629ee67a2dc504cb08d0a7eb 100644 (file)
@@ -507,7 +507,7 @@ func sm1(b []int, x int) {
        useSlice(b[2:8]) // ERROR "Proved slicemask not needed$"
        // Test non-constant argument with known limits.
        if cap(b) > 10 {
-               useSlice(b[2:]) // ERROR "Proved slicemask not needed$"
+               useSlice(b[2:])
        }
 }