Skip to content

Commit 2ac1f9c

Browse files
cuonglmgopherbot
authored andcommitted
cmd/compile: avoid unnecessary interface conversion in bloop
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>
1 parent de45645 commit 2ac1f9c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func getNameFromNode(n ir.Node) *ir.Name {
7474
}
7575

7676
// keepAliveAt returns a statement that is either curNode, or a
77-
// block containing curNode followed by a call to runtime.keepAlive for each
77+
// block containing curNode followed by a call to runtime.KeepAlive for each
7878
// node in ns. These calls ensure that nodes in ns will be live until
7979
// after curNode's execution.
8080
func keepAliveAt(ns []ir.Node, curNode ir.Node) ir.Node {
@@ -94,7 +94,7 @@ func keepAliveAt(ns []ir.Node, curNode ir.Node) ir.Node {
9494
if n.Sym().IsBlank() {
9595
continue
9696
}
97-
arg := ir.NewConvExpr(pos, ir.OCONV, types.Types[types.TINTER], n)
97+
arg := ir.NewConvExpr(pos, ir.OCONV, types.Types[types.TUNSAFEPTR], typecheck.NodAddr(n))
9898
if !n.Type().IsInterface() {
9999
srcRType0 := reflectdata.TypePtrAt(pos, n.Type())
100100
arg.TypeWord = srcRType0

test/bloop.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ func test(b *testing.B, localsink, cond int) { // ERROR ".*"
3131
}
3232
somethingptr := &something
3333
for b.Loop() { // ERROR "inlining call to testing\.\(\*B\)\.Loop"
34-
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
35-
caninlineNoRet(1) // ERROR "inlining call to caninlineNoRet" "function arg will be kept alive" ".* does not escape"
34+
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
35+
caninlineNoRet(1) // ERROR "inlining call to caninlineNoRet" "function arg will be kept alive"
3636
caninlineVariadic(1) // ERROR "inlining call to caninlineVariadic" "function arg will be kept alive" ".* does not escape"
3737
caninlineVariadic(localsink) // ERROR "inlining call to caninlineVariadic" "localsink will be kept alive" ".* does not escape"
38-
localsink = caninline(1) // ERROR "inlining call to caninline" "localsink will be kept alive" ".* does not escape"
39-
localsink += 5 // ERROR "localsink will be kept alive" ".* does not escape"
40-
localsink, cond = 1, 2 // ERROR "localsink will be kept alive" "cond will be kept alive" ".* does not escape"
38+
localsink = caninline(1) // ERROR "inlining call to caninline" "localsink will be kept alive"
39+
localsink += 5 // ERROR "localsink will be kept alive"
40+
localsink, cond = 1, 2 // ERROR "localsink will be kept alive" "cond will be kept alive"
4141
*somethingptr = 1 // ERROR "dereference will be kept alive"
4242
if cond > 0 {
43-
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
43+
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
4444
}
4545
switch cond {
4646
case 2:
47-
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
47+
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
4848
}
4949
{
50-
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive" ".* does not escape"
50+
caninline(1) // ERROR "inlining call to caninline" "function result will be kept alive"
5151
}
5252
}
5353
}

0 commit comments

Comments
 (0)