golang/go

cmd/cover: coverage instrumentation causes diff in gcflags=-m output

Closed this issue · 1 comments

thanm commented

What version of Go are you using (go version)?

$ go version
go version devel go1.20-d398025345 Fri Oct 28 11:18:38 2022 -0400 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

With this package:

package tiny

func Simple(x int) int {
	if x != 42 {
		return 42
	}
	return 42
}

func CallSimple() int {
	return Simple(42)
}

Do a build with "go build -gcflags=-m tiny" and then with "go build -gcflags=-m -cover tiny"

What did you expect to see?

Same "-m" output

What did you see instead?

The addition of "-cover" perturbs some of the output.

Here's the baseline (no "-cover"):

# cov.example/tiny
./tiny.go:3:6: can inline Simple
./tiny.go:10:6: can inline CallSimple
./tiny.go:11:15: inlining call to Simple

and here is with "-cover":

# cov.example/tiny
./tiny.go:3: can inline Simple
./tiny.go:10: can inline CallSimple
./tiny.go:11: inlining call to Simple

Note that we've lost the column information.

FWIW, this same problem seems to exist for "go test -cover" in previous versions of Go, so this doesn't appear to be a regression.

Change https://go.dev/cl/446259 mentions this issue: cmd/cover: fix buglet causing differences in -m output