]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: handle integer conversions in static init inliner
authorRuss Cox <rsc@golang.org>
Wed, 16 Nov 2022 21:04:08 +0000 (16:04 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 17 Nov 2022 13:46:05 +0000 (13:46 +0000)
commitbed970b3ffa81cd43ce520bdc75113dd069f41ef
treee4cb695448f70df05beb84782f48526cca8d65db
parentfee0ab8b5ecab3c1170a80300c8c41f09486ca66
cmd/compile: handle integer conversions in static init inliner

Given code like

func itou(i int) uint { return uint(i) }
var x = itou(-1)

the static inliner from CL 450136 was rewriting the code to

var x = uint(-1)

which is not valid Go code. Fix this by converting the
constants appropriately during inlining.

Fixes golang.org/x/image/vector test.

Change-Id: I13448df8504c6a70525b1cdc36e2c947e22cdd33
Reviewed-on: https://go-review.googlesource.com/c/go/+/451376
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/staticinit/sched.go
test/convinline.go [new file with mode: 0644]