aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/race.go20
-rw-r--r--test/codegen/stack.go11
2 files changed, 31 insertions, 0 deletions
diff --git a/test/codegen/race.go b/test/codegen/race.go
new file mode 100644
index 0000000000..ed6706f880
--- /dev/null
+++ b/test/codegen/race.go
@@ -0,0 +1,20 @@
+// asmcheck -race
+
+// Copyright 2019 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.
+
+package codegen
+
+// Check that we elide racefuncenter/racefuncexit for
+// functions with no calls (but which might panic
+// in various ways). See issue 31219.
+// amd64:-"CALL.*racefuncenter.*"
+func RaceMightPanic(a []int, i, j, k, s int) {
+ var b [4]int
+ _ = b[i] // panicIndex
+ _ = a[i:j] // panicSlice
+ _ = a[i:j:k] // also panicSlice
+ _ = i << s // panicShift
+ _ = i / j // panicDivide
+}
diff --git a/test/codegen/stack.go b/test/codegen/stack.go
index ed2c1ed959..ca37622286 100644
--- a/test/codegen/stack.go
+++ b/test/codegen/stack.go
@@ -98,3 +98,14 @@ func check_asmout(a, b int) int {
// arm:`.*b\+4\(FP\)`
return b
}
+
+// Check that simple functions get promoted to nosplit, even when
+// they might panic in various ways. See issue 31219.
+// amd64:"TEXT\t.*NOSPLIT.*"
+func MightPanic(a []int, i, j, k, s int) {
+ _ = a[i] // panicIndex
+ _ = a[i:j] // panicSlice
+ _ = a[i:j:k] // also panicSlice
+ _ = i << s // panicShift
+ _ = i / j // panicDivide
+}