]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: declare inlined result params early for empty returns
authorMatthew Dempsky <mdempsky@google.com>
Thu, 18 Feb 2021 01:49:40 +0000 (17:49 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 25 Feb 2021 19:57:49 +0000 (19:57 +0000)
commit6c3bcda866582b51842d71576a11c0fe1b647a22
tree77bfaf1a42dfa7d91481989c4bcaad5880a2cea7
parent526ee96f4992ff3a1e1c219fe8dc9870098bacba
cmd/compile: declare inlined result params early for empty returns

The code for delayed declaration of inlined result parameters only
handles non-empty return statements. This is generally okay, because
we already early declare if there are any (non-blank) named result
parameters.

But if a user writes a function with only blank result parameters and
with exactly one return statement, which is empty, then they could end
up hitting the dreaded "Value live at entry" ICE.

This CL fixes the issue by ensuring we always early declare inlined
result parameters if there are any empty return statements.

Fixes #44355.

Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506
Reviewed-on: https://go-review.googlesource.com/c/go/+/293293
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/inline/inl.go
test/fixedbugs/issue44355.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue44355.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue44355.go [new file with mode: 0644]