]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enable scopes unconditionally
authorDavid Chase <drchase@google.com>
Fri, 16 Mar 2018 19:15:50 +0000 (15:15 -0400)
committerDavid Chase <drchase@google.com>
Fri, 16 Mar 2018 20:25:10 +0000 (20:25 +0000)
This revives Alessandro Arzilli's CL to enable scopes
whenever any dwarf is emitted (with optimization or not),
adds a test that detects this changes and shows that it
creates more truthful debugging output.

Reverted change to ssa/debug_test tests made when
scopes were disabled during dwarflocationlist development.

Also included are updates to the Delve test output (it
had fallen out of sync; creating test output for one
updates it for all) and minor naming changes in
ssa/debug_test.

Compile-time/space changes (relative to tip including dwarflocationlists):

benchstat -geomean after.log scopes.log
name        old time/op     new time/op     delta
Template        182ms ± 1%      182ms ± 1%    ~     (p=0.666 n=9+9)
Unicode        82.8ms ± 1%     86.6ms ±14%    ~     (p=0.211 n=9+10)
GoTypes         611ms ± 1%      616ms ± 2%  +0.97%  (p=0.001 n=10+9)
Compiler        2.95s ± 1%      2.95s ± 0%    ~     (p=0.573 n=10+8)
SSA             6.70s ± 1%      6.81s ± 1%  +1.68%  (p=0.000 n=9+10)
Flate           117ms ± 1%      118ms ± 1%  +0.60%  (p=0.036 n=9+8)
GoParser        145ms ± 1%      145ms ± 1%    ~     (p=1.000 n=9+9)
Reflect         398ms ± 1%      396ms ± 1%    ~     (p=0.053 n=9+10)
Tar             171ms ± 1%      171ms ± 1%    ~     (p=0.356 n=9+10)
XML             214ms ± 1%      214ms ± 1%    ~     (p=0.605 n=9+9)
StdCmd          12.4s ± 2%      12.4s ± 1%    ~     (p=1.000 n=9+9)
[Geo mean]      506ms           509ms       +0.71%

name        old user-ns/op  new user-ns/op  delta
Template         254M ± 4%       249M ± 6%    ~     (p=0.155 n=10+10)
Unicode          121M ±11%       124M ± 6%    ~     (p=0.516 n=10+10)
GoTypes          824M ± 2%       869M ± 5%  +5.49%  (p=0.001 n=8+10)
Compiler        4.01G ± 2%      4.02G ± 1%    ~     (p=0.561 n=9+9)
SSA             10.0G ± 2%      10.2G ± 2%  +2.29%  (p=0.000 n=9+10)
Flate            154M ± 7%       154M ± 7%    ~     (p=0.960 n=10+9)
GoParser         190M ± 7%       196M ± 6%    ~     (p=0.064 n=9+10)
Reflect          528M ± 2%       517M ± 3%  -1.97%  (p=0.025 n=10+10)
Tar              227M ± 5%       232M ± 3%    ~     (p=0.061 n=9+10)
XML              286M ± 4%       283M ± 4%    ~     (p=0.343 n=9+9)
[Geo mean]       502M            508M       +1.09%

name        old text-bytes  new text-bytes  delta
HelloSize        672k ± 0%       672k ± 0%  +0.01%  (p=0.000 n=10+10)
CmdGoSize       7.21M ± 0%      7.21M ± 0%  -0.00%  (p=0.000 n=10+10)
[Geo mean]      2.20M           2.20M       +0.00%

name        old data-bytes  new data-bytes  delta
HelloSize       9.88k ± 0%      9.88k ± 0%    ~     (all equal)
CmdGoSize        248k ± 0%       248k ± 0%    ~     (all equal)
[Geo mean]      49.5k           49.5k       +0.00%

name        old bss-bytes   new bss-bytes   delta
HelloSize        125k ± 0%       125k ± 0%    ~     (all equal)
CmdGoSize        144k ± 0%       144k ± 0%  -0.04%  (p=0.000 n=10+10)
[Geo mean]       135k            135k       -0.02%

name        old exe-bytes   new exe-bytes   delta
HelloSize       1.30M ± 0%      1.34M ± 0%  +3.15%  (p=0.000 n=10+10)
CmdGoSize       13.5M ± 0%      13.9M ± 0%  +2.70%  (p=0.000 n=10+10)
[Geo mean]      4.19M           4.31M       +2.92%

Change-Id: Id53b8d57bd00440142ccbd39b95710e14e083fb5
Reviewed-on: https://go-review.googlesource.com/101217
Reviewed-by: Heschi Kreinick <heschi@google.com>
13 files changed:
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/ssa/debug_test.go
src/cmd/compile/internal/ssa/testdata/hist.dlv-opt.nexts
src/cmd/compile/internal/ssa/testdata/hist.gdb-dbg.nexts
src/cmd/compile/internal/ssa/testdata/hist.gdb-opt.nexts
src/cmd/compile/internal/ssa/testdata/hist.go
src/cmd/compile/internal/ssa/testdata/i22558.dlv-dbg.nexts [moved from src/cmd/compile/internal/ssa/testdata/i22558.dlv-dbg-22558.nexts with 100% similarity]
src/cmd/compile/internal/ssa/testdata/i22558.gdb-dbg.nexts [moved from src/cmd/compile/internal/ssa/testdata/i22558.gdb-dbg-22558.nexts with 100% similarity]
src/cmd/compile/internal/ssa/testdata/scopes.dlv-dbg.nexts [new file with mode: 0644]
src/cmd/compile/internal/ssa/testdata/scopes.dlv-opt.nexts [new file with mode: 0644]
src/cmd/compile/internal/ssa/testdata/scopes.gdb-dbg.nexts [new file with mode: 0644]
src/cmd/compile/internal/ssa/testdata/scopes.gdb-opt.nexts [new file with mode: 0644]
src/cmd/compile/internal/ssa/testdata/scopes.go [new file with mode: 0644]

index 2fa7ef84f5c17a165a17d5a4d7eeafef03d7338b..d0e85c9d9ef77e39e27c303c92d986508b90474f 100644 (file)
@@ -405,7 +405,7 @@ func Main(archInit func(*Arch)) {
                Debug['l'] = 1 - Debug['l']
        }
 
-       trackScopes = flagDWARF && (Debug['l'] == 0 && Debug['N'] != 0)
+       trackScopes = flagDWARF
 
        Widthptr = thearch.LinkArch.PtrSize
        Widthreg = thearch.LinkArch.RegSize
index b066816dc96d2c6ea8db701cbf23acb9079b780d..ff9f17525be0df7fc7db1800262a36fcab45ee17 100644 (file)
@@ -136,22 +136,27 @@ func TestNexting(t *testing.T) {
        }
 
        optFlags := "" // Whatever flags are needed to test debugging of optimized code.
+       dbgFlags := "-N -l"
        if !*useDelve && !*inlines {
                // For gdb (default), disable inlining so that a compiler test does not depend on library code.
                // TODO: Technically not necessary in 1.10, but it causes a largish regression that needs investigation.
                optFlags += " -l"
        }
 
-       subTest(t, debugger+"-dbg", "hist", "-N -l")
-       subTest(t, debugger+"-dbg-race", "i22600", "-N -l", "-race")
-       subTest(t, debugger+"-dbg-22558", "i22558", "-N -l")
+       subTest(t, debugger+"-dbg", "hist", dbgFlags)
+       subTest(t, debugger+"-dbg", "scopes", dbgFlags)
+       subTest(t, debugger+"-dbg", "i22558", dbgFlags)
+
+       subTest(t, debugger+"-dbg-race", "i22600", dbgFlags, "-race")
+
        optSubTest(t, debugger+"-opt", "hist", optFlags)
+       optSubTest(t, debugger+"-opt", "scopes", optFlags)
 }
 
 // subTest creates a subtest that compiles basename.go with the specified gcflags and additional compiler arguments,
 // then runs the debugger on the resulting binary, with any comment-specified actions matching tag triggered.
 func subTest(t *testing.T, tag string, basename string, gcflags string, moreargs ...string) {
-       t.Run(tag, func(t *testing.T) {
+       t.Run(tag+"-"+basename, func(t *testing.T) {
                testNexting(t, basename, tag, gcflags, moreargs...)
        })
 }
@@ -161,7 +166,7 @@ func subTest(t *testing.T, tag string, basename string, gcflags string, moreargs
 func optSubTest(t *testing.T, tag string, basename string, gcflags string, moreargs ...string) {
        // If optimized test is run with unoptimized libraries (compiled with -N -l), it is very likely to fail.
        // This occurs in the noopt builders (for example).
-       t.Run(tag, func(t *testing.T) {
+       t.Run(tag+"-"+basename, func(t *testing.T) {
                if *force || optimizedLibs {
                        testNexting(t, basename, tag, gcflags, moreargs...)
                } else {
index b98e3c6e65e7c3307c51d24095e71ff0757c724d..a7bcbb1ade307675bd0bc2e0fc381ed17e65d103 100644 (file)
@@ -57,8 +57,6 @@
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 86:            for i, a := range hist {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
-88:                            continue
-87:                    if a == 0 { //gdb-opt=(a,n,t)
 92:                    fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t)
 91:                    n += a
 92:                    fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t)
@@ -79,8 +77,6 @@
 86:            for i, a := range hist {
 92:                    fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t)
 87:                    if a == 0 { //gdb-opt=(a,n,t)
-88:                            continue
-87:                    if a == 0 { //gdb-opt=(a,n,t)
 92:                    fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t)
 91:                    n += a
 92:                    fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t)
 86:            for i, a := range hist {
 92:                    fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t)
 87:                    if a == 0 { //gdb-opt=(a,n,t)
-88:                            continue
 98:    }
index 91b4f2d23f5a4b204bfb5d457bcf9f9234b19061..fe000147bde4f07bc243aefd55703aab13606bcf 100644 (file)
@@ -14,64 +14,64 @@ hist =  []int = {0, 0, 0, 0, 0, 0, 0}
 73:            scanner := bufio.NewScanner(reader)
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 1
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 1
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 1
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 2
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 2
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 2
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 4
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 4
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
 i = 5
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
index d943eb1d58f52aa3d794e4bd991b92689e82676a..79c65a928833b5216ea1855230f6498ce9a21aa2 100644 (file)
@@ -22,9 +22,9 @@ dy = <Optimized out, as expected>
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 0, 0, 0, 0, 0, 0}
 i = 1
 81:                    hist = ensure(int(i), hist)
@@ -32,9 +32,9 @@ i = 1
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 1, 0, 0, 0, 0, 0}
 i = 1
 81:                    hist = ensure(int(i), hist)
@@ -42,9 +42,9 @@ i = 1
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 2, 0, 0, 0, 0, 0}
 i = 1
 81:                    hist = ensure(int(i), hist)
@@ -52,9 +52,9 @@ i = 1
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 3, 0, 0, 0, 0, 0}
 i = 2
 81:                    hist = ensure(int(i), hist)
@@ -62,9 +62,9 @@ i = 2
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 3, 1, 0, 0, 0, 0}
 i = 2
 81:                    hist = ensure(int(i), hist)
@@ -72,9 +72,9 @@ i = 2
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 3, 2, 0, 0, 0, 0}
 i = 2
 81:                    hist = ensure(int(i), hist)
@@ -82,9 +82,9 @@ i = 2
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 3, 3, 0, 0, 0, 0}
 i = 4
 81:                    hist = ensure(int(i), hist)
@@ -92,9 +92,9 @@ i = 4
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 3, 3, 0, 1, 0, 0}
 i = 4
 81:                    hist = ensure(int(i), hist)
@@ -102,9 +102,9 @@ i = 4
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
 scanner = (struct bufio.Scanner *) <A>
 75:                    s := scanner.Text()
-76:                    i, err2 := strconv.ParseInt(s, 10, 64)
-77:                    if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-err2 = {tab = 0x0, data = 0x0}
+76:                    i, err := strconv.ParseInt(s, 10, 64)
+77:                    if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+err = {tab = 0x0, data = 0x0}
 hist =  []int = {0, 3, 3, 0, 2, 0, 0}
 i = 5
 81:                    hist = ensure(int(i), hist)
index 1462ff64dec9a95f4af32d0e9c5cf48bf494d1e9..8a0cc2728081abee0f54c47e2414a42c0fac5cba 100644 (file)
@@ -73,9 +73,9 @@ func test() {
        scanner := bufio.NewScanner(reader)
        for scanner.Scan() { //gdb-opt=(scanner/A)
                s := scanner.Text()
-               i, err2 := strconv.ParseInt(s, 10, 64)
-               if err2 != nil { //gdb-dbg=(i) //gdb-opt=(err2,hist,i)
-                       fmt.Fprintf(os.Stderr, "There was an error: %v\n", err2)
+               i, err := strconv.ParseInt(s, 10, 64)
+               if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i)
+                       fmt.Fprintf(os.Stderr, "There was an error: %v\n", err)
                        return
                }
                hist = ensure(int(i), hist)
diff --git a/src/cmd/compile/internal/ssa/testdata/scopes.dlv-dbg.nexts b/src/cmd/compile/internal/ssa/testdata/scopes.dlv-dbg.nexts
new file mode 100644 (file)
index 0000000..3a49afc
--- /dev/null
@@ -0,0 +1,19 @@
+  ./testdata/scopes.go
+18:    func test() {
+19:            x := id(0)
+20:            y := id(0)
+21:            fmt.Println(x)
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+26:            y = x + y //gdb-dbg=(x,y)//gdb-opt=(x,y)
+27:            fmt.Println(x, y)
+28:    }
+11:    }
diff --git a/src/cmd/compile/internal/ssa/testdata/scopes.dlv-opt.nexts b/src/cmd/compile/internal/ssa/testdata/scopes.dlv-opt.nexts
new file mode 100644 (file)
index 0000000..749f1d3
--- /dev/null
@@ -0,0 +1,27 @@
+  ./testdata/scopes.go
+18:    func test() {
+19:            x := id(0)
+20:            y := id(0)
+21:            fmt.Println(x)
+18:    func test() {
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+22:            for i := x; i < 3; i++ {
+27:            fmt.Println(x, y)
+26:            y = x + y //gdb-dbg=(x,y)//gdb-opt=(x,y)
+27:            fmt.Println(x, y)
+28:    }
+11:    }
diff --git a/src/cmd/compile/internal/ssa/testdata/scopes.gdb-dbg.nexts b/src/cmd/compile/internal/ssa/testdata/scopes.gdb-dbg.nexts
new file mode 100644 (file)
index 0000000..0304128
--- /dev/null
@@ -0,0 +1,27 @@
+  src/cmd/compile/internal/ssa/testdata/scopes.go
+18:    func test() {
+19:            x := id(0)
+20:            y := id(0)
+21:            fmt.Println(x)
+0:
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 0
+y = 0
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 1
+y = 0
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 4
+y = 1
+22:            for i := x; i < 3; i++ {
+26:            y = x + y //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 0
+y = 5
+27:            fmt.Println(x, y)
+0: 5
+11:    }
diff --git a/src/cmd/compile/internal/ssa/testdata/scopes.gdb-opt.nexts b/src/cmd/compile/internal/ssa/testdata/scopes.gdb-opt.nexts
new file mode 100644 (file)
index 0000000..290f02f
--- /dev/null
@@ -0,0 +1,41 @@
+  src/cmd/compile/internal/ssa/testdata/scopes.go
+18:    func test() {
+19:            x := id(0)
+20:            y := id(0)
+21:            fmt.Println(x)
+0:
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 0
+y = 0
+22:            for i := x; i < 3; i++ {
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = <optimized out>
+y = 0
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 1
+y = 0
+22:            for i := x; i < 3; i++ {
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = <optimized out>
+y = 0
+22:            for i := x; i < 3; i++ {
+23:                    x := i * i
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 4
+y = 1
+22:            for i := x; i < 3; i++ {
+24:                    y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = <optimized out>
+y = 1
+22:            for i := x; i < 3; i++ {
+27:            fmt.Println(x, y)
+26:            y = x + y //gdb-dbg=(x,y)//gdb-opt=(x,y)
+x = 0
+y = 1
+27:            fmt.Println(x, y)
+0: 5
+11:    }
diff --git a/src/cmd/compile/internal/ssa/testdata/scopes.go b/src/cmd/compile/internal/ssa/testdata/scopes.go
new file mode 100644 (file)
index 0000000..9434aba
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "fmt"
+
+func main() {
+       test()
+}
+
+//go:noinline
+func id(x int) int {
+       return x
+}
+
+func test() {
+       x := id(0)
+       y := id(0)
+       fmt.Println(x)
+       for i := x; i < 3; i++ {
+               x := i * i
+               y += id(x) //gdb-dbg=(x,y)//gdb-opt=(x,y)
+       }
+       y = x + y //gdb-dbg=(x,y)//gdb-opt=(x,y)
+       fmt.Println(x, y)
+}