]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use generated temps in bool codegen
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 8 Jun 2015 23:21:50 +0000 (16:21 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 9 Jun 2015 17:38:26 +0000 (17:38 +0000)
Bool codegen was generating a temp for function calls
and other complex expressions, but was not using it.

This was a refactoring bug introduced by CL 7853.
The cmp code used to do (in short):

l, r := &n1, &n2

It was changed to:

l, r := nl, nr

But the requisite assignments:

nl, nr = &n1, &n2

were only introduced on one of two code paths.

Fixes #10654.

Change-Id: Ie8de0b3a333842a048d4308e02911bb10c6915ce
Reviewed-on: https://go-review.googlesource.com/10844
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/cgen.go
test/fixedbugs/issue10654.go [new file with mode: 0644]

index f40ca9e374bc8900ff2a7c5d1f23af58ce6a07f8..4160ae9d402f374f9216c9b57829b24e8fad2916 100644 (file)
@@ -2007,6 +2007,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
                var n1 Node
                Regalloc(&n1, nl.Type, nil)
                Cgen(nl, &n1)
+               nl = &n1
 
                var tmp Node
                Tempname(&tmp, nl.Type)
@@ -2016,6 +2017,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
                var n2 Node
                Regalloc(&n2, nr.Type, nil)
                Cgen(nr, &n2)
+               nr = &n2
                Regfree(&n2)
 
                Regalloc(&n1, nl.Type, nil)
diff --git a/test/fixedbugs/issue10654.go b/test/fixedbugs/issue10654.go
new file mode 100644 (file)
index 0000000..0600a80
--- /dev/null
@@ -0,0 +1,17 @@
+// compile
+
+// Copyright 2015 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.
+
+// Issue 10654: Failure to use generated temps
+// for function calls etc. in boolean codegen.
+
+package main
+
+var s string
+
+func main() {
+       if (s == "this") != (s == "that") {
+       }
+}