]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.1] cmd/6g, cmd/8g: prevent constant propagation of non-constant...
authorAndrew Gerrand <adg@golang.org>
Mon, 22 Jul 2013 22:00:01 +0000 (08:00 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 22 Jul 2013 22:00:01 +0000 (08:00 +1000)
««« CL 10785043 / cf792c00f410
cmd/6g, cmd/8g: prevent constant propagation of non-constant LEA.

Fixes #5809.

R=golang-dev, dave, rsc, nigeltao
CC=golang-dev
https://golang.org/cl/10785043
»»»

Update #5928

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11515045

src/cmd/6g/peep.c
src/cmd/8g/peep.c
test/fixedbugs/issue5809.go [new file with mode: 0644]

index bb24d41449eb82d9ba6ed203e2de88483a2205b5..cd2881ec40276de010bbf308c889f8c215708cd4 100644 (file)
@@ -152,6 +152,7 @@ peep(void)
                case ALEAQ:
                        if(regtyp(&p->to))
                        if(p->from.sym != S)
+                       if(p->from.index == D_NONE || p->from.index == D_CONST)
                                conprop(r);
                        break;
 
index e5a3149cf1a7dd7d74cd2f5c221a10a34c96b8b0..b8a1eaa08dc134c213c75cf30f9dc248e51b0cd2 100644 (file)
@@ -145,6 +145,7 @@ peep(void)
                case ALEAL:
                        if(regtyp(&p->to))
                        if(p->from.sym != S)
+                       if(p->from.index == D_NONE || p->from.index == D_CONST)
                                conprop(r);
                        break;
 
diff --git a/test/fixedbugs/issue5809.go b/test/fixedbugs/issue5809.go
new file mode 100644 (file)
index 0000000..ca060b5
--- /dev/null
@@ -0,0 +1,27 @@
+// run
+
+// Copyright 2013 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 5809: 6g and 8g attempted to constant propagate indexed LEA
+
+package main
+
+import "fmt"
+
+func main() {
+       const d16 = "0123456789ABCDEF"
+       k := 0x1234
+       var x [4]byte
+       
+       x[0] = d16[k>>12&0xf]
+       x[1] = d16[k>>8&0xf]
+       x[2] = d16[k>>4&0xf]
+       x[3] = d16[k&0xf]
+       
+       if x != [4]byte{'1','2','3','4'} {
+               fmt.Println(x)
+               panic("x != [4]byte{'1','2','3','4'}")
+       }
+}