]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: avoid unnecessary interface conversion in bloop
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 28 Nov 2025 10:19:42 +0000 (17:19 +0700)
committerGopher Robot <gobot@golang.org>
Fri, 28 Nov 2025 23:18:43 +0000 (15:18 -0800)
Fixes #76482

Change-Id: I076568d8ae92ad6c9e0a5797cfe5bbfb615f63d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/725180
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

src/cmd/compile/internal/bloop/bloop.go
test/bloop.go

index e4a86d891420fe7d47fda440ac500d2ff1763c4b..761b07abd4de6c20a9aec572c79dad5353be172a 100644 (file)
@@ -74,7 +74,7 @@ func getNameFromNode(n ir.Node) *ir.Name {
 }
 
 // keepAliveAt returns a statement that is either curNode, or a
-// block containing curNode followed by a call to runtime.keepAlive for each
+// block containing curNode followed by a call to runtime.KeepAlive for each
 // node in ns. These calls ensure that nodes in ns will be live until
 // after curNode's execution.
 func keepAliveAt(ns []ir.Node, curNode ir.Node) ir.Node {
@@ -94,7 +94,7 @@ func keepAliveAt(ns []ir.Node, curNode ir.Node) ir.Node {
                if n.Sym().IsBlank() {
                        continue
                }
-               arg := ir.NewConvExpr(pos, ir.OCONV, types.Types[types.TINTER], n)
+               arg := ir.NewConvExpr(pos, ir.OCONV, types.Types[types.TUNSAFEPTR], typecheck.NodAddr(n))
                if !n.Type().IsInterface() {
                        srcRType0 := reflectdata.TypePtrAt(pos, n.Type())
                        arg.TypeWord = srcRType0
index a19d8345b000cc601c4ce1786105880be3e90080..fd22132dbfa7f22b5195022b7135a328c2990af6 100644 (file)
@@ -31,23 +31,23 @@ func test(b *testing.B, localsink, cond int) { // ERROR ".*"
        }
        somethingptr := &something
        for b.Loop() { // ERROR "inlining call to testing\.\(\*B\)\.Loop"
-               caninline(1)                 // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
-               caninlineNoRet(1)            // ERROR "inlining call to caninlineNoRet" "function arg will be kept alive" ".* does not escape"
+               caninline(1)                 // ERROR "inlining call to caninline" "function result will be kept alive"
+               caninlineNoRet(1)            // ERROR "inlining call to caninlineNoRet" "function arg will be kept alive"
                caninlineVariadic(1)         // ERROR "inlining call to caninlineVariadic" "function arg will be kept alive" ".* does not escape"
                caninlineVariadic(localsink) // ERROR "inlining call to caninlineVariadic" "localsink will be kept alive" ".* does not escape"
-               localsink = caninline(1)     // ERROR "inlining call to caninline" "localsink will be kept alive" ".* does not escape"
-               localsink += 5               // ERROR "localsink will be kept alive" ".* does not escape"
-               localsink, cond = 1, 2       // ERROR "localsink will be kept alive" "cond will be kept alive" ".* does not escape"
+               localsink = caninline(1)     // ERROR "inlining call to caninline" "localsink will be kept alive"
+               localsink += 5               // ERROR "localsink will be kept alive"
+               localsink, cond = 1, 2       // ERROR "localsink will be kept alive" "cond will be kept alive"
                *somethingptr = 1            // ERROR "dereference will be kept alive"
                if cond > 0 {
-                       caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
+                       caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
                }
                switch cond {
                case 2:
-                       caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
+                       caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
                }
                {
-                       caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
+                       caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
                }
        }
 }