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
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 04989d9..58c5669 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -2171,11 +2171,11 @@
return v
case "Hash":
v.reset(OpConst32)
- v.AuxInt = int64(types.TypeHash(t))
+ v.AuxInt = int64(int32(types.TypeHash(t)))
return v
case "Kind_":
v.reset(OpConst8)
- v.AuxInt = int64(reflectdata.ABIKindOfType(t))
+ v.AuxInt = int64(int8(reflectdata.ABIKindOfType(t)))
return v
case "GCData":
gcdata, _ := reflectdata.GCSym(t, true)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Gentle ping.
+CC: CL 701297's author and reviewers
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Code-Review | +2 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Will this need to be backported to 1.26?
Ah yes. This will fix the only failing CI test in go{1.26,tip}-linux-mipsle, see https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8689298350493009505/+/u/step/22/log/2
I am not very sure what I should do to backport it, considering there is no "Fixes" issue for it. Should I simply open a cherry-pick CL via Gerrit after this gets merged?
And thanks for your review :)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
RongrongWill this need to be backported to 1.26?
Ah yes. This will fix the only failing CI test in go{1.26,tip}-linux-mipsle, see https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8689298350493009505/+/u/step/22/log/2
I am not very sure what I should do to backport it, considering there is no "Fixes" issue for it. Should I simply open a cherry-pick CL via Gerrit after this gets merged?
And thanks for your review :)
I opened 77785 for this issue, and gopherbot will open a backport issue for 1.26.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[release-branch.go1.26] 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
Fixes #77786
Change-Id: Ib4f3c94c0e3908698868449db2fdcdf4541f2e7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/744860
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>
LUCI-TryBot-Result: Go LUCI <golang...@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit a78df5aa0afcd64935f89577c0da0ed2315014ea)
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 032915f..29222ff 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -2169,11 +2169,11 @@
return v
case "Hash":
v.reset(OpConst32)
- v.AuxInt = int64(types.TypeHash(t))
+ v.AuxInt = int64(int32(types.TypeHash(t)))
return v
case "Kind_":
v.reset(OpConst8)
- v.AuxInt = int64(reflectdata.ABIKindOfType(t))
+ v.AuxInt = int64(int8(reflectdata.ABIKindOfType(t)))
return v
case "GCData":
gcdata, _ := reflectdata.GCSym(t, true)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |