golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.07k stars 17.68k forks source link

cmd/compile: ppc64 builds failing with ssa checker on #36723

Closed josharian closed 4 years ago

josharian commented 4 years ago

At tip now:

$ GOOS=linux GOARCH=ppc64 go build -gcflags="all=-d=ssa/check/on" -a std
# runtime
compile: invalid offset for DS form load/store 00096 (/Users/josh/go/tip/src/runtime/symtab.go:821) MOVW    1(R3), R3

Oddly, that error is coming from the assembler. Yet it doesn't occur with the flag off. Running with the SSA checker on shouldn't impact the generated code (I thought?).

At 1.13 we get different failures:

$ GOOS=linux GOARCH=ppc64 go build -gcflags="all=-d=ssa/check/on" -a std
# math
math/sqrt.go:102:14: internal compiler error: 'sqrt': val v149 is in reg but not live at end of b26
# runtime
runtime/malloc.go:414:18: internal compiler error: 'mallocinit': val v3 is in reg but not live at end of b15

Tentatively marking as Go 1.14 until we know whether we're actually generating bad code.

cc @dr2chase @randall77

josharian commented 4 years ago

Also, why isn't the ssa check builder isn't failing with this? Maybe... umm.. @dmitshur knows?

cherrymui commented 4 years ago

I think the SSA check builder only runs for AMD64. It doesn't do cross compilations.

cherrymui commented 4 years ago

Running with the SSA checker on shouldn't impact the generated code (I thought?).

I also thought so. But then I found this https://go.googlesource.com/go/+/refs/heads/master/src/cmd/compile/internal/ssa/compile.go#80

My guess is that it might catch a real bug that we (accidentally) depended on value ordering.

gopherbot commented 4 years ago

Change https://golang.org/cl/216379 mentions this issue: cmd/compile: on PPC64, fold offset into some loads/stores only when offset is 4-aligned

cherrymui commented 4 years ago

CL https://go-review.googlesource.com/c/go/+/216379 should fix the immediate problem.

When SSA check is on, the Values are reordered, which affects the ordering of rewriting rules firing (and eventually whether some rules are fired or not), which affects the compilation result.

josharian commented 4 years ago

Thanks, @cherrymui! (Although it's going to cause me a bunch of rebase pain. No good deed goes unpunished. :P)

We should probably find some way to run with SSA check on for all architectures, somewhere.

And IMHO, it'd be good to use different random seeds for different runs, to get better coverage. I now remember having that discussion with Keith when the CL first went by.

josharian commented 4 years ago

Filed https://github.com/golang/go/issues/36756 for the builder and sent https://go-review.googlesource.com/c/go/+/216418 for the seed randomization.

cherrymui commented 4 years ago

Tests in cmd/compile/internal/gc/ssa_test.go are run with SSA check enabled (on each host architecture). It covers basic operations but is not as complete as building std.

ceseo commented 4 years ago

cc @laboger