go icon indicating copy to clipboard operation
go copied to clipboard

cmd/compile/internal/test: TestAppendOfMake fails with GOEXPERIMENT=unified

Open dmitshur opened this issue 3 years ago • 3 comments

Observed in trybots of CL 420234:

--- FAIL: TestAppendOfMake (0.00s)
    issue53888_test.go:29: got 1.000000 allocs, want 0
    issue53888_test.go:41: got 1.000000 allocs, want 0
FAIL
FAIL	cmd/compile/internal/test	9.922s

(https://storage.googleapis.com/go-build-log/7622dec8/linux-amd64-unified_f57873d7.log)

It seems to happen reproducibly by looking at build.golang.org, though it's less noticeable because the builder is marked as having a known issue #52150. Still, the builder is currently in the default TryBot set, so this needs attention.

CC @randall77.

dmitshur avatar Aug 08 '22 18:08 dmitshur

I think because CL 420234 is sent before dev.unified was merge to master, so the try-bot doesn't observe the failure earlier.

Unified IR currently re-write the IR as:

before walk genericExtend[[]uint8,uint8]-shaped
.   AS tc(1) # r.go:11:22
.   .   NAME-p..autotmp_4 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used int tc(1) # r.go:11:22
.   .   CAP int tc(1) # r.go:11:22
.   .   .   NAME-p.s esc(no) Class:PPARAM Offset:0 OnStack Used SLICE-[]byte tc(1) # r.go:10:35
.   AS tc(1) # r.go:11:17
.   .   NAME-p..autotmp_5 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used SLICE-[]byte tc(1) # r.go:11:17
.   .   SLICE SLICE-[]byte tc(1) # r.go:11:17
.   .   .   NAME-p.s esc(no) Class:PPARAM Offset:0 OnStack Used SLICE-[]byte tc(1) # r.go:10:35
.   .   SLICE-High
.   .   .   NAME-p..autotmp_4 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used int tc(1) # r.go:11:22
.   AS tc(1) # r.go:11:32
.   .   NAME-p..autotmp_6 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used SLICE-[]byte tc(1) # r.go:11:32
.   .   MAKESLICE esc(h) SLICE-[]byte tc(1) # r.go:11:32
.   .   MAKESLICE-RType
.   .   .   CONVNOP PTR-*uint8 tc(1) # r.go:11:32
.   .   .   .   INDEX uintptr tc(1) # r.go:11:32
.   .   .   .   .   DEREF Implicit ARRAY-[6]uintptr tc(1) # r.go:11:32
.   .   .   .   .   .   NAME-p..dict esc(no) Class:PPARAM Offset:0 OnStack Used PTR-*[6]uintptr tc(1) # r.go:10:6
.   .   .   .   .   LITERAL-1 int tc(1) # r.go:11:32
.   .   MAKESLICE-Len
.   .   .   NAME-p.n esc(no) Class:PPARAM Offset:0 OnStack Used int tc(1) # r.go:10:40
.   AS tc(1) # r.go:11:15
.   .   NAME-p..autotmp_7 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used SLICE-[]byte tc(1) # r.go:11:15
.   .   APPEND IsDDD SLICE-[]byte tc(1) # r.go:11:15
.   .   APPEND-Args
.   .   .   NAME-p..autotmp_5 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used SLICE-[]byte tc(1) # r.go:11:17
.   .   .   CONVNOP Implicit SLICE-[]byte tc(1) # r.go:11:15
.   .   .   .   NAME-p..autotmp_6 esc(N) Class:PAUTO Offset:0 AutoTemp OnStack Used SLICE-[]byte tc(1) # r.go:11:32
.   .   APPEND-RType
.   .   .   CONVNOP PTR-*uint8 tc(1) # r.go:11:15
.   .   .   .   INDEX uintptr tc(1) # r.go:11:15
.   .   .   .   .   DEREF Implicit ARRAY-[6]uintptr tc(1) # r.go:11:15
.   .   .   .   .   .   NAME-p..dict esc(no) Class:PPARAM Offset:0 OnStack Used PTR-*[6]uintptr tc(1) # r.go:10:6
.   .   .   .   .   LITERAL-1 int tc(1) # r.go:11:15

So the append of make form isn't detected so the optimization is skipped.

Also cc @mdempsky

cuonglm avatar Aug 08 '22 18:08 cuonglm

Removing Soon label since CL 422037 added a " && !goexperiment.unified" build constraint, so the builder doesn't fail now. Thanks.

dmitshur avatar Aug 08 '22 18:08 dmitshur

Change https://go.dev/cl/422040 mentions this issue: cmd/compile: do not write implicit conversion for append in Unified IR

gopherbot avatar Aug 08 '22 20:08 gopherbot