aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/func_test.go
diff options
context:
space:
mode:
authorTodd Neal <todd@tneal.org>2016-03-08 22:13:20 -0600
committerTodd Neal <tolchz@gmail.com>2016-03-10 10:28:05 +0000
commit6cb2e1d015b87f4627f40d7b208b58ecb4e102e1 (patch)
tree7365686a3083f82bd68c0c078e75a26bc42cf9c9 /src/cmd/compile/internal/ssa/func_test.go
parentdbe54d23fe2b2751872aaf41d1ef3179729b9960 (diff)
downloadgo-6cb2e1d015b87f4627f40d7b208b58ecb4e102e1.tar.gz
go-6cb2e1d015b87f4627f40d7b208b58ecb4e102e1.zip
cmd/compile: remove values from const cache upon free
When calling freeValue for possible const values, remove them from the cache as well. Change-Id: I087ed592243e33c58e5db41700ab266fc70196d9 Reviewed-on: https://go-review.googlesource.com/20481 Run-TryBot: Todd Neal <tolchz@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/func_test.go')
-rw-r--r--src/cmd/compile/internal/ssa/func_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/func_test.go b/src/cmd/compile/internal/ssa/func_test.go
index fa6a1a8751..4fef782afc 100644
--- a/src/cmd/compile/internal/ssa/func_test.go
+++ b/src/cmd/compile/internal/ssa/func_test.go
@@ -421,6 +421,28 @@ func TestEquiv(t *testing.T) {
}
}
+// TestConstCache ensures that the cache will not return
+// reused free'd values with a non-matching AuxInt
+func TestConstCache(t *testing.T) {
+ f := Fun(testConfig(t), "entry",
+ Bloc("entry",
+ Valu("mem", OpInitMem, TypeMem, 0, nil),
+ Exit("mem")))
+ v1 := f.f.ConstBool(0, TypeBool, false)
+ v2 := f.f.ConstBool(0, TypeBool, true)
+ f.f.freeValue(v1)
+ f.f.freeValue(v2)
+ v3 := f.f.ConstBool(0, TypeBool, false)
+ v4 := f.f.ConstBool(0, TypeBool, true)
+ if v3.AuxInt != 0 {
+ t.Errorf("expected %s to have auxint of 0\n", v3.LongString())
+ }
+ if v4.AuxInt != 1 {
+ t.Errorf("expected %s to have auxint of 1\n", v4.LongString())
+ }
+
+}
+
// opcodeMap returns a map from opcode to the number of times that opcode
// appears in the function.
func opcodeMap(f *Func) map[Op]int {