aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-08-18 05:20:16 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-08-18 17:26:40 +0000
commit52016be3f4e6deba54020ad8c969f1e2dba1eee3 (patch)
treef21300cf8800232712e559cd4068b4690d5edeb6 /test
parentd6294e00f029d93b8552827bce1f24f67458d3f2 (diff)
downloadgo-52016be3f4e6deba54020ad8c969f1e2dba1eee3.tar.xz
cmd/compile: enable more inlining for unified IR
The non-unified frontend had repeated issues with inlining and generics (#49309, #51909, #52907), which led us to substantially restrict inlining when shape types were present. However, these issues are evidently not present in unified IR's inliner, and the safety restrictions added for the non-unified frontend can simply be disabled in unified mode. Fixes #54497. Change-Id: I8e6ac9f3393c588bfaf14c6452891b9640a9d1bd Reviewed-on: https://go-review.googlesource.com/c/go/+/424775 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/run.go1
-rw-r--r--test/typeparam/issue49309.go1
-rw-r--r--test/typeparam/issue54497.go19
3 files changed, 21 insertions, 0 deletions
diff --git a/test/run.go b/test/run.go
index cdbe15c389..21f0f7d634 100644
--- a/test/run.go
+++ b/test/run.go
@@ -1990,6 +1990,7 @@ var go118Failures = setOf(
"fixedbugs/issue54343.go", // 1.18 compiler assigns receiver parameter to global variable
"typeparam/nested.go", // 1.18 compiler doesn't support function-local types with generics
"typeparam/issue51521.go", // 1.18 compiler produces bad panic message and link error
+ "typeparam/issue54497.go", // 1.18 compiler is more conservative about inlining due to repeated issues
"typeparam/mdempsky/16.go", // 1.18 compiler uses interface shape type in failed type assertions
"typeparam/mdempsky/17.go", // 1.18 compiler mishandles implicit conversions from range loops
"typeparam/mdempsky/18.go", // 1.18 compiler mishandles implicit conversions in select statements
diff --git a/test/typeparam/issue49309.go b/test/typeparam/issue49309.go
index 265e0bf525..16c97cd451 100644
--- a/test/typeparam/issue49309.go
+++ b/test/typeparam/issue49309.go
@@ -18,6 +18,7 @@ func myfunc(c string) {
//go:noinline
func test2(a interface{}) {
+ _ = a.(string)
}
func main() {
diff --git a/test/typeparam/issue54497.go b/test/typeparam/issue54497.go
new file mode 100644
index 0000000000..1b24cd9afb
--- /dev/null
+++ b/test/typeparam/issue54497.go
@@ -0,0 +1,19 @@
+// errorcheck -0 -m
+
+// Copyright 2022 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.
+
+// Test that inlining works with generic functions.
+
+package testcase
+
+type C interface{ ~uint | ~uint32 | ~uint64 }
+
+func isAligned[T C](x, y T) bool { // ERROR "can inline isAligned\[uint\]" "can inline isAligned\[go\.shape\.uint\]" "inlining call to isAligned\[go\.shape\.uint\]"
+ return x%y == 0
+}
+
+func foo(x uint) bool { // ERROR "can inline foo"
+ return isAligned(x, 64) // ERROR "inlining call to isAligned\[go\.shape\.uint\]"
+}