]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove statement marks from secondary calls
authorDavid Chase <drchase@google.com>
Mon, 29 Jul 2019 20:23:31 +0000 (16:23 -0400)
committerDavid Chase <drchase@google.com>
Fri, 4 Oct 2019 20:41:52 +0000 (20:41 +0000)
Calls are code-generated in an alternate path that inherits
its positions from values, not from *SSAGenState.  The
default position on *SSAGenState was marked as not-a-statement,
but this was not applied to the value itself, leading to
spurious "is statement" marks in the output (convention:
after code generation in the compiler, everything is either
definitely a statement or definitely not a statement, nothing
is in the undetermined state).

This CL causes a 35 statement regression in ssa/stmtlines_test.
This is down from the earlier 150 because of all the other
CLs preceding this one that deal with the root causes of the
missing lines (repeated lines on nested calls hid missing lines).

This also removes some line repeats from ssa/debug_test.

Change-Id: Ie9a507bd5447e906b35bbd098e3295211df2ae01
Reviewed-on: https://go-review.googlesource.com/c/go/+/188018
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/gc/ssa.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

index ed1cccc6b0ab09922a6b3379c8e0a62ae00d8b93..a263fa7e996baf4c48521b141a0f3118253b218c 100644 (file)
@@ -5238,8 +5238,11 @@ func (s *SSAGenState) DebugFriendlySetPosFrom(v *ssa.Value) {
                        // in the generated code.
                        if p.IsStmt() != src.PosIsStmt {
                                p = p.WithNotStmt()
+                               // Calls use the pos attached to v, but copy the statement mark from SSAGenState
                        }
                        s.SetPos(p)
+               } else {
+                       s.SetPos(s.pp.pos.WithNotStmt())
                }
        }
 }
@@ -5878,10 +5881,15 @@ func (s *SSAGenState) AddrScratch(a *obj.Addr) {
 // Call returns a new CALL instruction for the SSA value v.
 // It uses PrepareCall to prepare the call.
 func (s *SSAGenState) Call(v *ssa.Value) *obj.Prog {
+       pPosIsStmt := s.pp.pos.IsStmt() // The statement-ness fo the call comes from ssaGenState
        s.PrepareCall(v)
 
        p := s.Prog(obj.ACALL)
-       p.Pos = v.Pos
+       if pPosIsStmt == src.PosIsStmt {
+               p.Pos = v.Pos.WithIsStmt()
+       } else {
+               p.Pos = v.Pos.WithNotStmt()
+       }
        if sym, ok := v.Aux.(*obj.LSym); ok {
                p.To.Type = obj.TYPE_MEM
                p.To.Name = obj.NAME_EXTERN
index 1e4d35051b6b3e912969509399a82c723d832b6a..2be83ce9369343ba3b9ca03ac75f65edbc875610 100644 (file)
 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)
 90:                    t += i * 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 {
 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)
 90:                    t += i * 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 {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 86:            for i, a := range hist {
 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)
 90:                    t += i * 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 {
 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)
 90:                    t += i * 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 {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 86:            for i, a := range hist {
index 4fde3bcc66ba5c276f0204b372dafefc2ec067b0..72df60c76f49076e9a9378f9ef1a2608c9e4b712 100644 (file)
@@ -9,7 +9,7 @@ l.end.y = 4
 61:            sink = dx + dy            //gdb-opt=(dx,dy)
 63:            hist := make([]int, 7)                                //gdb-opt=(dx/O,dy/O) // TODO sink is missing if this code is in 'test' instead of 'main'
 64:            var reader io.Reader = strings.NewReader(cannedInput) //gdb-dbg=(hist/A) // TODO cannedInput/A is missing if this code is in 'test' instead of 'main'
-hist =  []int = {0, 0, 0, 0, 0, 0, 0}
+hist = {array = <A>, len = 7, cap = 7}
 65:            if len(os.Args) > 1 {
 73:            scanner := bufio.NewScanner(reader)
 74:            for scanner.Scan() { //gdb-opt=(scanner/A)
index 65c5d0a2cee417096ca1944e1bd3be610865c33d..d3a34acf691e7b4ba418bd5562d8d678d7828865 100644 (file)
@@ -24,92 +24,74 @@ scanner = (bufio.Scanner *) <A>
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 1
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 1
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 1
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 2
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 2
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 2
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 4
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 4
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 75:                    s := scanner.Text()
 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}
+hist = {array = 0xc00005ae50, len = 7, cap = 7}
 i = 5
 81:                    hist = ensure(int(i), hist)
 82:                    hist[int(i)]++
-74:            for scanner.Scan() { //gdb-opt=(scanner/A)
-scanner = (bufio.Scanner *) <A>
 86:            for i, a := range hist {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 a = 0
@@ -122,9 +104,7 @@ n = 0
 t = 0
 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)
 90:                    t += i * 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 {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 a = 3
@@ -132,9 +112,7 @@ n = 3
 t = 3
 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)
 90:                    t += i * 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 {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 a = 0
@@ -147,9 +125,7 @@ n = 6
 t = 9
 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)
 90:                    t += i * 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 {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 a = 1
@@ -157,9 +133,7 @@ n = 8
 t = 17
 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)
 90:                    t += i * 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 {
 87:                    if a == 0 { //gdb-opt=(a,n,t)
 a = 0