[go] cmd/compile: rewriteFixedLoad: ensure AuxInt is sign-extended

0 views
Skip to first unread message

Keith Randall (Gerrit)

unread,
1:26 AM (4 hours ago) 1:26 AM
to Keith Randall, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Cherry Mui, Keith Randall, Jake Bailey, Mark Freeman, Go LUCI, Julian Zhu, Martin Möhrmann, Gopher Robot, golang-co...@googlegroups.com

Keith Randall submitted the change

Change information

Commit message:
cmd/compile: rewriteFixedLoad: ensure AuxInt is sign-extended

CL 701297 accidentailly broke the type casting behavior for Hash.

Previously, the generated rules for Hash shared a common pattern:

v.AuxInt = int32ToAuxInt(fixed32(config, sym, off))

which inherently equaled to a signed-extend:

v.AuxInt = int64(int32(types.TypeHash(...)))

The pattern in CL 701297 was however:

v.AuxInt = int64(types.TypeHash(t))

Since types.TypeHash() returns a uint32, casting it to a wider integer
implies zero-extend. This diverges from the definition of AuxInt, in
which "Unused portions are filled by sign-extending the used portion,
even if the represented value is unsigned."

As a result, ssa.checkFunc(), where AuxInt is checked against the
mentioned rule, is unhappy and shouts:

internal compiler error: 'typeAsserts': bad int32 AuxInt value for v1317

Reproduce it with:

GOARCH=mips go tool compile -m -d=ssa/check/on test/devirtualization.go

This is only reproducible with GOARCH=mips/mipsle (cross and native).
Probably the rewrite rules of other architectures prevent Hash from
running into rewriteFixedLoad.

Fix it by emit sign-extend properly. Additionally, do the same for Kind_
as reflectdata.ABIKindOfType() also returns a fragile unsigned interger
(uint8).

Updates #67304
Change-Id: Ib4f3c94c0e3908698868449db2fdcdf4541f2e7e
Reviewed-by: Cherry Mui <cher...@google.com>
Reviewed-by: Jake Bailey <jacob.b...@gmail.com>
Reviewed-by: Keith Randall <k...@golang.org>
Auto-Submit: Keith Randall <k...@golang.org>
Reviewed-by: Keith Randall <k...@google.com>
Files:
  • M src/cmd/compile/internal/ssa/rewrite.go
Change size: XS
Delta: 1 file changed, 2 insertions(+), 2 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Jake Bailey, +2 by Keith Randall, +1 by Keith Randall, +1 by Cherry Mui
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ib4f3c94c0e3908698868449db2fdcdf4541f2e7e
Gerrit-Change-Number: 744860
Gerrit-PatchSet: 2
Gerrit-Owner: Rongrong <rongrong...@oss.cipunited.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Julian Zhu <jz53...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Martin Möhrmann <moeh...@google.com>
Gerrit-CC: Florian Lehner <lehner.f...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Mark Freeman <markf...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages