aboutsummaryrefslogtreecommitdiff
path: root/test/torture.go
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2012-11-02 07:50:59 +0100
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2012-11-02 07:50:59 +0100
commit0b2353edcb7fc6ff100f42b1d9cc5613a6c57da1 (patch)
treef34ed113df23bd103fffe7ea48a78c8da78351b8 /test/torture.go
parentd659633aff6c56997e4400bce0929ffd1efefb6e (diff)
downloadgo-0b2353edcb7fc6ff100f42b1d9cc5613a6c57da1.tar.gz
go-0b2353edcb7fc6ff100f42b1d9cc5613a6c57da1.zip
cmd/5g, cmd/6g: fix out of registers with array indexing.
Compiling expressions like: s[s[s[s[s[s[s[s[s[s[s[s[i]]]]]]]]]]]] make 5g and 6g run out of registers. Such expressions can arise if a slice is used to represent a permutation and the user wants to iterate it. This is due to the usual problem of allocating registers before going down the expression tree, instead of allocating them in a postfix way. The functions cgenr and agenr (that generate a value to a newly allocated register instead of an existing location), are either introduced or modified when they already existed to allocate the new register as late as possible, and sudoaddable is disabled for OINDEX nodes so that igen/agenr is used instead. Update #4207. R=dave, daniel.morsing, rsc CC=golang-dev https://golang.org/cl/6733055
Diffstat (limited to 'test/torture.go')
-rw-r--r--test/torture.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/torture.go b/test/torture.go
index 4bce3a1796..c510bb9237 100644
--- a/test/torture.go
+++ b/test/torture.go
@@ -116,6 +116,23 @@ func determinantByte(m [4][4]byte) byte {
m[0][3]*m[1][2]*m[2][1]*m[3][0]
}
+type A []A
+
+// A sequence of constant indexings.
+func IndexChain1(s A) A {
+ return s[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
+}
+
+// A sequence of non-constant indexings.
+func IndexChain2(s A, i int) A {
+ return s[i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i]
+}
+
+// Another sequence of indexings.
+func IndexChain3(s []int) int {
+ return s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[0]]]]]]]]]]]]]]]]]]]]]
+}
+
// A right-leaning tree of byte multiplications.
func righttree(a, b, c, d uint8) uint8 {
return a * (b * (c * (d *