Skip to content

Commit

Permalink
cmd/compile: get rid of zero-sized values in call expansion
Browse files Browse the repository at this point in the history
Do this by removing all stores of zero-sized anything.

Fixes #63433.

Change-Id: I5d8271edab992d15d02005fa3fe31835f2eff8fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/534296
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
dr2chase committed Oct 10, 2023
1 parent f34964a commit 1493dd3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cmd/compile/internal/ssa/_gen/dec.rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// types. These rules work together with the decomposeBuiltIn
// pass which handles phis of these types.

(Store {t} _ _ mem) && t.Size() == 0 => mem

// complex ops
(ComplexReal (ComplexMake real _ )) => real
(ComplexImag (ComplexMake _ imag )) => imag
Expand Down
12 changes: 12 additions & 0 deletions src/cmd/compile/internal/ssa/rewritedec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions test/fixedbugs/issue63490.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// compile

// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

type ResourceFunc struct {
junk [8]int
base assignmentBaseResource
}

type SubscriptionAssignmentResource struct {
base assignmentBaseResource
}

type assignmentBaseResource struct{}

//go:noinline
func (a assignmentBaseResource) f(s string) ResourceFunc {
println(s)
return ResourceFunc{}
}

//go:noinline
func (r SubscriptionAssignmentResource) Hi() ResourceFunc {
rf := r.base.f("Hello world")
rf.base = r.base
return rf
}

func main() {
var r SubscriptionAssignmentResource
r.Hi()
}

0 comments on commit 1493dd3

Please sign in to comment.